X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Ftests%2Fxestiaab_common.h;h=5777b31dd66d91ef202b1017410e2f37b921afae;hp=49391785d7c64fb449a07684f057619cc5649d8d;hb=eb1f61ec533689192be474bd941931d49933a0fa;hpb=1c98aaa412ec1110cc69c5189a7339c10e8c1bbe
diff --git a/source/tests/xestiaab_common.h b/source/tests/xestiaab_common.h
index 4939178..5777b31 100644
--- a/source/tests/xestiaab_common.h
+++ b/source/tests/xestiaab_common.h
@@ -551,72 +551,298 @@ TEST(CommonFunctions, GivenStringWithSeveralCharactersWhenResetUnusedStringThenS
}
-TEST(CommonFunctions, ConvertToHTML){
+TEST(CommonFunctions, GivenStringWhenConvertToHTMLIsCalledThenStringisHTMLEscaped){
// Tests for converting data for inserting into a HTML
// formatted document.
+ // Given
+
wxString ConvertToHTMLData = "The test line where < is probably better than >!";
+
+ // When
+
ConvertToHTML(&ConvertToHTMLData);
+
+ // Then
+
ASSERT_EQ("The test line where < is probably better than >!", ConvertToHTMLData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenStringWithNewlineWhenConvertToHTMLIsCalledThenStringIsHTMLEscapedWithFormattedNewline){
+
+ // Tests for converting data for inserting into a HTML
+ // formatted document.
+
+ // Given
+
ConvertToHTMLData = "More testing &<>\n";
+
+ // When
+
ConvertToHTML(&ConvertToHTMLData);
+
+ // Then
+
ASSERT_EQ("More testing &<>
", ConvertToHTMLData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenStringWithSeveralLinesWhenConvertToHTMLIsCalledThenStringIsHTMLEscapedWithFormattedNewlines){
+
+ // Tests for converting data for inserting into a HTML
+ // formatted document.
+
+ // Given
+
ConvertToHTMLData = "This is the first line.\nThis is the second line.\nThis is the third line.";
+
+ // When
+
ConvertToHTML(&ConvertToHTMLData);
+
+ // Then
+
ASSERT_EQ("This is the first line.
This is the second line.
This is the third line.", ConvertToHTMLData.ToStdString());
}
-TEST(CommonFunctions, MapDataExists){
+static std::map MapExample;
+static int itemIndex = 0;
+
+static MapExample.insert(std::make_pair(0,1));
+static MapExample.insert(std::make_pair(1,1));
+static MapExample.insert(std::make_pair(2,1));
+static MapExample.insert(std::make_pair(5,1));
+static MapExample.insert(std::make_pair(500,1));
+static MapExample.insert(std::make_pair(2415,1));
+static mapExistsStatus = false;
+
+TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs0WhenMapDataExistsIsCalledThenConfirmItemIndex0DoesExist){
+
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapExistsStatus = false;
+ itemIndex = 0;
+
+ // When
+
+ mapExistsStatus = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(true, mapExistsStatus);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs1WhenMapDataExistsIsCalledThenConfirmItemIndex1DoesExist){
+
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapExistsStatus = false;
+ itemIndex = 1;
+
+ // When
+
+ mapExistsStatus = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(true, mapExistsStatus);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs2WhenMapDataExistsIsCalledThenConfirmItemIndex2DoesExist){
+
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapStatusExists = false;
+ itemIndex = 2;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(true, mapStatusExists);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs3WhenMapDataExistsIsCalledThenConfirmItemIndex3DoesntExist){
+
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapStatusExists = true;
+ itemIndex = 3;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(false, mapStatusExists);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs5WhenMapDataExistsIsCalledThenConfirmItemIndex5DoesExist){
+
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapStatusExists = false;
+ itemIndex = 5;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(true, mapStatusExists);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs6WhenMapDataExistsIsCalledThenConfirmItemIndex6DoesntExist){
// Tests for checking that map data exists.
- std::map MapExample;
- int ItemIndex = 0;
+ // Given
- MapExample.insert(std::make_pair(0,1));
- MapExample.insert(std::make_pair(1,1));
- MapExample.insert(std::make_pair(2,1));
- MapExample.insert(std::make_pair(5,1));
- MapExample.insert(std::make_pair(500,1));
- MapExample.insert(std::make_pair(2415,1));
+ mapStatusExists = true;
+ itemIndex = 6;
+
+ // When
- ASSERT_EQ(true, MapDataExists(&ItemIndex, &MapExample));
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(false, mapStatusExists);
- ItemIndex = 1;
- ASSERT_EQ(true, MapDataExists(&ItemIndex, &MapExample));
+}
- ItemIndex = 2;
- ASSERT_EQ(true, MapDataExists(&ItemIndex, &MapExample));
+TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs499WhenMapDataExistsIsCalledThenConfirmItemIndex499DoesntExist){
- ItemIndex = 3;
- ASSERT_EQ(false, MapDataExists(&ItemIndex, &MapExample));
+ // Tests for checking that map data exists.
- ItemIndex = 5;
- ASSERT_EQ(true, MapDataExists(&ItemIndex, &MapExample));
+ // Given
- ItemIndex = 6;
- ASSERT_EQ(false, MapDataExists(&ItemIndex, &MapExample));
+ mapStatusExists = false;
+ itemIndex = 499;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(false, mapStatusExists);
- ItemIndex = 499;
- ASSERT_EQ(false, MapDataExists(&ItemIndex, &MapExample));
+}
- ItemIndex = 500;
- ASSERT_EQ(true, MapDataExists(&ItemIndex, &MapExample));
+TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs500WhenMapDataExistsIsCalledThenConfirmItemIndex500DoesExist){
- ItemIndex = 501;
- ASSERT_EQ(false, MapDataExists(&ItemIndex, &MapExample));
+ // Tests for checking that map data exists.
- ItemIndex = 2414;
- ASSERT_EQ(false, MapDataExists(&ItemIndex, &MapExample));
+ // Given
- ItemIndex = 2415;
- ASSERT_EQ(true, MapDataExists(&ItemIndex, &MapExample));
+ mapStatusExists = false;
+ itemIndex = 500;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(true, mapStatusExists);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs501WhenMapDataExistsIsCalledThenConfirmItemIndex501DoesntExist){
- ItemIndex = 2416;
- ASSERT_EQ(false, MapDataExists(&ItemIndex, &MapExample));
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapStatusExists = true;
+ itemIndex = 501;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(false, mapStatusExists);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs2414WhenMapDataExistsIsCalledThenConfirmItemIndex2414DoesntExist){
+
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapStatusExists = true;
+ itemIndex = 2414;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(false, mapStatusExists);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs2415WhenMapDataExistsIsCalledThenConfirmItemIndex2415DoesExist){
+
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapStatusExists = false;
+ itemIndex = 2415;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(true, mapStatusExists);
+
+}
+
+TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs2416WhenMapDataExistsIsCalledThenConfirmItemIndex2416DoesntExist){
+
+ // Tests for checking that map data exists.
+
+ // Given
+
+ mapStatusExists = true;
+ itemIndex = 2416;
+
+ // When
+
+ mapStatusExists = MapDataExists(&itemIndex, &MapExample);
+
+ // Then
+
+ ASSERT_EQ(false, mapStatusExists);
}
\ No newline at end of file