}
-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 &<><br>", 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.<br>This is the second line.<br>This is the third line.", ConvertToHTMLData.ToStdString());
}
-TEST(CommonFunctions, MapDataExists){
+static std::map<int,int> 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<int,int> 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