diff options
Diffstat (limited to 'src/gui/sdlfont_unittest.cc')
-rw-r--r-- | src/gui/sdlfont_unittest.cc | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gui/sdlfont_unittest.cc b/src/gui/sdlfont_unittest.cc index a372d2867..7575772f0 100644 --- a/src/gui/sdlfont_unittest.cc +++ b/src/gui/sdlfont_unittest.cc @@ -35,6 +35,7 @@ TEST(TextChunkList, empty) EXPECT_EQ(nullptr, list.start); EXPECT_EQ(nullptr, list.end); EXPECT_EQ(0, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, add1) @@ -53,9 +54,11 @@ TEST(TextChunkList, add1) EXPECT_EQ(nullptr, chunk->next); EXPECT_EQ(1, list.search.size()); - EXPECT_EQ(chunk, (*list.search.find(SDLTextChunkSmall( chunk->text, chunk->color, chunk->color2))).second); + + EXPECT_EQ(1, list.searchWidth.size()); + EXPECT_EQ(chunk, (*list.searchWidth.find(chunk->text)).second); } TEST(TextChunkList, add2) @@ -77,11 +80,15 @@ TEST(TextChunkList, add2) EXPECT_EQ(chunk2, chunk1->next); EXPECT_EQ(chunk1, chunk2->prev); EXPECT_EQ(nullptr, chunk2->next); + EXPECT_EQ(2, list.search.size()); EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); EXPECT_EQ(chunk2, (*list.search.find(SDLTextChunkSmall( chunk2->text, chunk2->color, chunk2->color2))).second); + + EXPECT_EQ(1, list.searchWidth.size()); + EXPECT_EQ(chunk1, (*list.searchWidth.find(chunk1->text)).second); } TEST(TextChunkList, addRemoveBack1) @@ -98,6 +105,7 @@ TEST(TextChunkList, addRemoveBack1) EXPECT_EQ(nullptr, list.start); EXPECT_EQ(nullptr, list.end); EXPECT_EQ(0, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, addRemoveBack2) @@ -118,9 +126,13 @@ TEST(TextChunkList, addRemoveBack2) EXPECT_EQ(chunk1, list.end); EXPECT_EQ(nullptr, chunk1->prev); EXPECT_EQ(nullptr, chunk1->next); + EXPECT_EQ(1, list.search.size()); EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); + + EXPECT_EQ(1, list.searchWidth.size()); + EXPECT_EQ(chunk1, (*list.searchWidth.find(chunk1->text)).second); } TEST(TextChunkList, addRemoveBack3) @@ -139,7 +151,9 @@ TEST(TextChunkList, addRemoveBack3) EXPECT_EQ(0, list.size); EXPECT_EQ(nullptr, list.start); EXPECT_EQ(nullptr, list.end); + EXPECT_EQ(0, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, addRemoveBack4) @@ -164,9 +178,12 @@ TEST(TextChunkList, addRemoveBack4) EXPECT_EQ(chunk1, list.end); EXPECT_EQ(nullptr, chunk1->prev); EXPECT_EQ(nullptr, chunk1->next); + EXPECT_EQ(1, list.search.size()); EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); + + EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, moveToFirst1) @@ -274,6 +291,7 @@ TEST(TextChunkList, clear1) EXPECT_EQ(nullptr, list.end); EXPECT_EQ(chunksLeft, sdlTextChunkCnt); EXPECT_EQ(0, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, clear2) @@ -298,6 +316,7 @@ TEST(TextChunkList, clear2) EXPECT_EQ(nullptr, list.end); EXPECT_EQ(chunksLeft, sdlTextChunkCnt); EXPECT_EQ(0, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, clear3) @@ -318,14 +337,17 @@ TEST(TextChunkList, clear3) list.moveToFirst(chunk1); EXPECT_EQ(chunksLeft + 3, sdlTextChunkCnt); EXPECT_EQ(3, list.search.size()); + EXPECT_EQ(1, list.searchWidth.size()); list.removeBack(); EXPECT_EQ(chunksLeft + 2, sdlTextChunkCnt); EXPECT_EQ(2, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); list.clear(); EXPECT_EQ(chunksLeft, sdlTextChunkCnt); EXPECT_EQ(0, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, clear4) @@ -346,14 +368,17 @@ TEST(TextChunkList, clear4) list.moveToFirst(chunk2); EXPECT_EQ(chunksLeft + 3, sdlTextChunkCnt); EXPECT_EQ(3, list.search.size()); + EXPECT_EQ(2, list.searchWidth.size()); list.removeBack(2); EXPECT_EQ(chunksLeft + 1, sdlTextChunkCnt); EXPECT_EQ(1, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); list.clear(); EXPECT_EQ(chunksLeft, sdlTextChunkCnt); EXPECT_EQ(0, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, sort1) |