MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / TEST

Function TEST

source/test/small_vector_test.cpp:8–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace Star;
7
8TEST(SmallVectorTest, InsertErase) {
9 typedef SmallVector<int, 2> SV;
10 SV a = {1, 2, 3, 4};
11 EXPECT_EQ(a.size(), 4u);
12 EXPECT_EQ(a, SV({1, 2, 3, 4}));
13 EXPECT_NE(a, SV({1, 2, 3}));
14 a.insert(a.begin(), 0);
15 a.insert(a.begin(), -1);
16 EXPECT_EQ(a, SV({-1, 0, 1, 2, 3, 4}));
17 a.insert(a.begin(), {-3, -2});
18 EXPECT_EQ(a, SV({-3, -2, -1, 0, 1, 2, 3, 4}));
19 a.erase(a.begin() + 1);
20 EXPECT_EQ(a, SV({-3, -1, 0, 1, 2, 3, 4}));
21 a.erase(a.begin(), a.begin() + 3);
22 EXPECT_EQ(a, SV({1, 2, 3, 4}));
23 a.insert(a.end(), {5, 6, 7, 8});
24 EXPECT_EQ(a, SV({1, 2, 3, 4, 5, 6, 7, 8}));
25 a.erase(a.begin() + 2, a.end() - 2);
26 EXPECT_EQ(a, SV({1, 2, 7, 8}));
27 a.insert(a.begin() + 2, 6);
28 a.insert(a.begin() + 2, 5);
29 a.insert(a.begin() + 2, 4);
30 a.insert(a.begin() + 2, 3);
31 EXPECT_EQ(a, SV({1, 2, 3, 4, 5, 6, 7, 8}));
32
33 SV b(a.begin(), a.end());
34 EXPECT_EQ(b, SV({1, 2, 3, 4, 5, 6, 7, 8}));
35}
36
37TEST(SmallVectorTest, Comparators) {
38 typedef SmallVector<int, 3> SV;

Callers

nothing calls this directly

Calls 8

sizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
pop_backMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected