From ba3ba5de4e84a8c3ddeb65549d0b46998e5ebdf5 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Tue, 31 Oct 2017 21:57:54 +0000 Subject: [PATCH] Unit Tests: Clean up of Common, ContactLoad and ContactSave tests --- source/tests/xestiaab_common.h | 95 ++++++++++++++--------------- source/tests/xestiaab_contactload.h | 2 +- source/tests/xestiaab_contactsave.h | 16 ++--- 3 files changed, 55 insertions(+), 58 deletions(-) diff --git a/source/tests/xestiaab_common.h b/source/tests/xestiaab_common.h index 4739afb..ca9b727 100644 --- a/source/tests/xestiaab_common.h +++ b/source/tests/xestiaab_common.h @@ -370,7 +370,7 @@ TEST(CommonFunctions, GivenStringWithCommaWhenEscapeStringIsCalledThenCommaIsEsc // Given - EscapeStringData = "Here we go, an \"example\" of escaping string."; + wxString EscapeStringData = "Here we go, an \"example\" of escaping string."; // When @@ -389,7 +389,7 @@ TEST(CommonFunctions, GivenStringWithNewlineCharactersWhenEscapeStringIsCalledTh // Given - EscapeStringData = "Lets put some \nnew \nlines \nin \nhere."; + wxString EscapeStringData = "Lets put some \nnew \nlines \nin \nhere."; // When @@ -408,7 +408,7 @@ TEST(CommonFunctions, GivenAStringWithReturnCharactersWhenEscapeStringIsCalledTh // Given - EscapeStringData = "Lets put some \r\nnew \r\nlines \r\nin \r\nhere."; + wxString EscapeStringData = "Lets put some \r\nnew \r\nlines \r\nin \r\nhere."; // When @@ -427,7 +427,7 @@ TEST(CommonFunctions, GivenStringWithBackslashesWhenEscapeStringIsCalledThenBack // Given - EscapeStringData = "A:\\path\\example\\lets\\have\\some\\fun"; + wxString EscapeStringData = "A:\\path\\example\\lets\\have\\some\\fun"; // When @@ -465,7 +465,7 @@ TEST(CommonFunctions, GivenStringWithEscapedCommasWhenCaptureStringIsCalledThenC // Given - CaptureStringData = "Here we go\\, an \"example\" of escaping string."; + wxString CaptureStringData = "Here we go\\, an \"example\" of escaping string."; // When @@ -484,7 +484,7 @@ TEST(CommonFunctions, GivenStringWithEscapedNewlinesWhenCaptureStringIsCalledThe // Given - CaptureStringData = "Lets put some \\nnew \\nlines \\nin \\nhere."; + wxString CaptureStringData = "Lets put some \\nnew \\nlines \\nin \\nhere."; // When @@ -503,7 +503,7 @@ TEST(CommonFunctions, GivenStringWithEscapedBackslashesWhenCaptureStringIsCalled // Given - CaptureStringData = "A:\\\\path\\\\example\\\\lets\\\\have\\\\some\\\\fun"; + wxString CaptureStringData = "A:\\\\path\\\\example\\\\lets\\\\have\\\\some\\\\fun"; // When @@ -541,7 +541,7 @@ TEST(CommonFunctions, GivenStringWithNewlinesWhenResetUnusedStringIsCalledThenSt // Given - ResetUnusedStringData = "Some text \\nwith new \\nlines!"; + wxString ResetUnusedStringData = "Some text \\nwith new \\nlines!"; // When @@ -560,7 +560,7 @@ TEST(CommonFunctions, GivenStringWithSeveralCharactersWhenResetUnusedStringThenS // Given - ResetUnusedStringData = "And now the list of characters: \\\\ \\n \\; \\,"; + wxString ResetUnusedStringData = "And now the list of characters: \\\\ \\n \\; \\,"; // When @@ -600,7 +600,7 @@ TEST(CommonFunctions, GivenStringWithNewlineWhenConvertToHTMLIsCalledThenStringI // Given - ConvertToHTMLData = "More testing &<>\n"; + wxString ConvertToHTMLData = "More testing &<>\n"; // When @@ -620,7 +620,7 @@ TEST(CommonFunctions, GivenStringWithSeveralLinesWhenConvertToHTMLIsCalledThenSt // Given - ConvertToHTMLData = "This is the first line.\nThis is the second line.\nThis is the third line."; + wxString ConvertToHTMLData = "This is the first line.\nThis is the second line.\nThis is the third line."; // When @@ -632,16 +632,13 @@ TEST(CommonFunctions, GivenStringWithSeveralLinesWhenConvertToHTMLIsCalledThenSt } -static std::map mapExample; +static std::map mapExample = +{ + { 0, 1 }, { 1, 1 }, { 2, 1 }, { 5, 1 }, { 500, 1 }, { 2415, 1 } +}; 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; +bool mapExistsStatus = false; TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs0WhenMapDataExistsIsCalledThenConfirmItemIndex0DoesExist) { @@ -690,16 +687,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs2WhenMapDataExist // Given - mapStatusExists = false; + mapExistsStatus = false; itemIndex = 2; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(true, mapStatusExists); + ASSERT_EQ(true, mapExistsStatus); } @@ -710,16 +707,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs3WhenMapDataExists // Given - mapStatusExists = true; + mapExistsStatus = true; itemIndex = 3; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(false, mapStatusExists); + ASSERT_EQ(false, mapExistsStatus); } @@ -730,16 +727,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs5WhenMapDataExist // Given - mapStatusExists = false; + mapExistsStatus = false; itemIndex = 5; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(true, mapStatusExists); + ASSERT_EQ(true, mapExistsStatus); } @@ -750,16 +747,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs6WhenMapDataExists // Given - mapStatusExists = true; + mapExistsStatus = true; itemIndex = 6; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(false, mapStatusExists); + ASSERT_EQ(false, mapExistsStatus); } @@ -770,16 +767,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs499WhenMapDataExi // Given - mapStatusExists = false; + mapExistsStatus = false; itemIndex = 499; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(false, mapStatusExists); + ASSERT_EQ(false, mapExistsStatus); } @@ -790,16 +787,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs500WhenMapDataExi // Given - mapStatusExists = false; + mapExistsStatus = false; itemIndex = 500; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(true, mapStatusExists); + ASSERT_EQ(true, mapExistsStatus); } @@ -810,16 +807,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs501WhenMapDataExis // Given - mapStatusExists = true; + mapExistsStatus = true; itemIndex = 501; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(false, mapStatusExists); + ASSERT_EQ(false, mapExistsStatus); } @@ -830,16 +827,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs2414WhenMapDataExi // Given - mapStatusExists = true; + mapExistsStatus = true; itemIndex = 2414; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(false, mapStatusExists); + ASSERT_EQ(false, mapExistsStatus); } @@ -850,16 +847,16 @@ TEST(CommonFunctions, GivenMapExistsStatusIsFalseAndItemIndexIs2415WhenMapDataEx // Given - mapStatusExists = false; + mapExistsStatus = false; itemIndex = 2415; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(true, mapStatusExists); + ASSERT_EQ(true, mapExistsStatus); } @@ -870,15 +867,15 @@ TEST(CommonFunctions, GivenMapExistsStatusIsTrueAndItemIndexIs2416WhenMapDataExi // Given - mapStatusExists = true; + mapExistsStatus = true; itemIndex = 2416; // When - mapStatusExists = MapDataExists(&itemIndex, &mapExample); + mapExistsStatus = MapDataExists(&itemIndex, &mapExample); // Then - ASSERT_EQ(false, mapStatusExists); + ASSERT_EQ(false, mapExistsStatus); } \ No newline at end of file diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index cb625bb..86564ed 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -29,7 +29,7 @@ TEST(ContactLoad, GivenContactDataObjectWhenLoadFileIsCalledWithMissingFileThenR // When ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL; - testFile.LoadFile("MissingFile.vcf"); + testFileLoadStatus = testFile.LoadFile("MissingFile.vcf"); // Then diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index 0ddf8f9..c1f8b9a 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -38,7 +38,7 @@ TEST(ContactSave, GivenAContactDataObjectWhenSaveStringIsCalledThenContactDataSa ContactDataObject testFile; ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL; - testFileLoadStatus = testFile1.LoadFile("LoadCheck-Load1.vcf"); + testFileLoadStatus = testFile.LoadFile("LoadCheck-Load1.vcf"); ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus); @@ -729,14 +729,14 @@ TEST(ContactSave, GivenSeveralContactFilesWhenLoadFileAndSaveFileIsCalledThenCon ContactDataObject testFile2; ContactDataObject testFile3; - ContactLoadStatus testFile1SaveStatus = CONTACTSAVE_UNITTESTFAIL; - ContactSaveStatus testFile1LoadStatus = CONTACTLOAD_UNITTESTFAIL; + ContactLoadStatus testFile1LoadStatus = CONTACTLOAD_UNITTESTFAIL; + ContactSaveStatus testFile1SaveStatus = CONTACTSAVE_UNITTESTFAIL; - ContactLoadStatus testFile2SaveStatus = CONTACTSAVE_UNITTESTFAIL; - ContactSaveStatus testFile2LoadStatus = CONTACTLOAD_UNITTESTFAIL; + ContactLoadStatus testFile2LoadStatus = CONTACTLOAD_UNITTESTFAIL; + ContactSaveStatus testFile2SaveStatus = CONTACTSAVE_UNITTESTFAIL; - ContactLoadStatus testFile3SaveStatus = CONTACTSAVE_UNITTESTFAIL; - ContactSaveStatus testFile3LoadStatus = CONTACTLOAD_UNITTESTFAIL; + ContactLoadStatus testFile3LoadStatus = CONTACTLOAD_UNITTESTFAIL; + ContactSaveStatus testFile3SaveStatus = CONTACTSAVE_UNITTESTFAIL; // When @@ -771,7 +771,7 @@ TEST(ContactSave, GivenContactDataObjectWhenFileIsSavedToInvalidLocationThenErro ContactLoadStatus testFileLoadStatus = CONTACTLOAD_UNITTESTFAIL; ContactSaveStatus testFileSaveStatus = CONTACTSAVE_UNITTESTFAIL; - testFileLoadStatus = testFile1.LoadFile("LoadCheck-Load1.vcf"); + testFileLoadStatus = testFile.LoadFile("LoadCheck-Load1.vcf"); ASSERT_EQ(CONTACTLOAD_OK, testFileLoadStatus); -- 2.39.5