Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
vector_tests.cpp File Reference
#include <algorithm>
#include <vector>
#include <iterator>
#include <cstdlib>
#include <fstream>
#include <string>
#include <catch2/catch.hpp>
#include <sysio/vm/vector.hpp>
Include dependency graph for vector_tests.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("unmanaged_vector tests", "[unmanaged_vector_tests]")
 
 TEST_CASE ("managed_vector tests", "[managed_vector_tests]")
 

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "managed_vector tests" ,
"" [managed_vector_tests] )

Definition at line 53 of file vector_tests.cpp.

53 {
54 bounded_allocator ba(20);
56 for (int i = 0; i < v0.size(); i++)
57 v0[i] = 'a';
58 CHECK_THROWS_AS([&](){ v0[10] = 'a'; }(), std::exception);
59 v0.resize(10);
60 v0[9] = 'a';
61 CHECK_THROWS_AS([&](){ v0[10] = 'a'; }(), std::exception);
62 v0.resize(8);
63 CHECK_THROWS_AS([&](){ v0[8] = 'a'; }(), std::exception);
64 size_t v0_size = v0.size();
66 CHECK( v0_size == v1.size() );
67 for (int i=0; i < v1.size(); i++)
68 v1[i] = 'b';
69 v1.emplace_back('b');
70 for (int i=0; i < 7; i++)
71 v1.emplace_back('c');
72 CHECK_THROWS_AS([&]() {v1.emplace_back('c');}(), std::exception);
73}
#define CHECK(cond)
Definition util.h:80
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
Here is the call graph for this function:

◆ TEST_CASE() [2/2]

TEST_CASE ( "unmanaged_vector tests" ,
"" [unmanaged_vector_tests] )

Definition at line 15 of file vector_tests.cpp.

15 {
16 {
18 for (int i = 0; i < uv0.size(); i++)
19 uv0[i] = 'a';
20 CHECK_THROWS_AS([&](){ uv0.at(10) = 'a'; }(), std::exception);
21 uv0.resize(11);
22 uv0[10] = 'a';
23 CHECK_THROWS_AS([&](){ uv0.at(11) = 'a'; }(), std::exception);
24 uv0.resize(8);
25 CHECK_THROWS_AS([&](){ uv0.at(8) = 'a'; }(), std::exception);
26 size_t uv0_size = uv0.size();
27 unmanaged_vector<char> uv1(std::move(uv0));
28 CHECK( uv0_size == uv1.size() );
29 for (int i=0; i < uv1.size(); i++)
30 uv1[i] = 'b';
31 uv1.emplace_back('b');
32 for (int i=0; i < 8; i++)
33 uv1.emplace_back('c');
34 uv1.emplace_back('c');
35 for (int i=0; i < 16; i++)
36 uv1.emplace_back('d');
37 }
38
39 {
41 for (int i=0; i < uv0.size(); i++)
42 uv0[i] = 'b';
43 uv0.push_back('b');
44 uv0.push_back('b');
45 for (int i=0; i < 8; i++)
46 uv0.push_back('c');
47 uv0.push_back('c');
48 for (int i=0; i < 16; i++)
49 uv0.push_back('d');
50 }
51}
std::vector< T > unmanaged_vector
Definition vector.hpp:108