}
-TEST(CommonFunctions, EscapeString){
+TEST(CommonFunctions, GivenExampleStringWhenEscapeStringIsCalledThenReturnedStringIsExample){
// Test the escape string function.
+ // Given
+
wxString EscapeStringData = "Example";
+
+ // When
+
EscapeString(&EscapeStringData, false);
+
+ // Then
+
ASSERT_EQ("Example", EscapeStringData.ToStdString());
+
+}
+
+TEST(CommonFunctions, GivenStringWithCommaWhenEscapeStringIsCalledThenCommaIsEscaped){
+
+ // Test the escape string function.
+
+ // Given
EscapeStringData = "Here we go, an \"example\" of escaping string.";
+
+ // When
+
EscapeString(&EscapeStringData, false);
+
+ // Then
+
ASSERT_EQ("Here we go\\, an \"example\" of escaping string.", EscapeStringData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenStringWithNewlineCharactersWhenEscapeStringIsCalledThenNewlinesAreEscaped){
+
+ // Test the escape string function.
+
+ // Given
+
EscapeStringData = "Lets put some \nnew \nlines \nin \nhere.";
+
+ // When
+
EscapeString(&EscapeStringData, false);
+
+ // Then
+
ASSERT_EQ("Lets put some \\nnew \\nlines \\nin \\nhere.", EscapeStringData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenAStringWithReturnCharactersWhenEscapeStringIsCalledThenReturnsAreRemoved){
+
+ // Test the escape string function.
+
+ // Given
+
EscapeStringData = "Lets put some \r\nnew \r\nlines \r\nin \r\nhere.";
+
+ // When
+
EscapeString(&EscapeStringData, false);
+
+ // Then
+
ASSERT_EQ("Lets put some \\nnew \\nlines \\nin \\nhere.", EscapeStringData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenStringWithBackslashesWhenEscapeStringIsCalledThenBackslashesAreEscaped){
+
+ // Test the escape string function.
+
+ // Given
+
EscapeStringData = "A:\\path\\example\\lets\\have\\some\\fun";
+
+ // When
+
EscapeString(&EscapeStringData, false);
+
+ // Then
+
ASSERT_EQ("A:\\\\path\\\\example\\\\lets\\\\have\\\\some\\\\fun", EscapeStringData.ToStdString());
}
-TEST(CommonFunctions, CaptureString){
+TEST(CommonFunctions, GivenExampleStringWhenCaptureStringIsCalledThenReturnedStringIsExample){
// Test the capture string function.
+ // Given
+
wxString CaptureStringData = "Example";
+
+ // When
+
CaptureString(&CaptureStringData, false);
+
+ // Then
+
ASSERT_EQ("Example", CaptureStringData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenStringWithEscapedCommasWhenCaptureStringIsCalledThenCommasAreCaptured){
+
+ // Test the capture string function.
+
+ // Given
+
CaptureStringData = "Here we go\\, an \"example\" of escaping string.";
+
+ // When
+
CaptureString(&CaptureStringData, false);
+
+ // Then
+
ASSERT_EQ("Here we go, an \"example\" of escaping string.", CaptureStringData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenStringWithEscapedNewlinesWhenCaptureStringIsCalledThenNewlinesAreCaptured){
+
+ // Test the capture string function.
+
+ // Given
+
CaptureStringData = "Lets put some \\nnew \\nlines \\nin \\nhere.";
+
+ // When
+
CaptureString(&CaptureStringData, false);
+
+ // Then
+
ASSERT_EQ("Lets put some \nnew \nlines \nin \nhere.", CaptureStringData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenStringWithEscapedBackslashesWhenCaptureStringIsCalledThenBackslashesAreCaptured){
+
+ // Test the capture string function.
+
+ // Given
+
CaptureStringData = "A:\\\\path\\\\example\\\\lets\\\\have\\\\some\\\\fun";
+
+ // When
+
CaptureString(&CaptureStringData, false);
+
+ // Then
+
ASSERT_EQ("A:\\path\\example\\lets\\have\\some\\fun", CaptureStringData.ToStdString());
}
-TEST(CommonFunctions, ResetUnusedString){
+TEST(CommonFunctions, GivenStringWithSeveralBackslashesWhenResetUnusedStringIsCalledThenStringIsReset){
// Tests for resetting an unused string.
+ // Given
+
wxString ResetUnusedStringData = "Random string with a \\\\\\\\serverpath\\\\location";
+
+ // When
+
ResetUnusedString(&ResetUnusedStringData);
+
+ // Then
+
ASSERT_EQ("Random string with a \\\\serverpath\\location", ResetUnusedStringData.ToStdString());
- ResetUnusedStringData = "Some text \\nwith new \\nlines!";
- ResetUnusedString(&ResetUnusedStringData);
- ASSERT_EQ("Some text \nwith new \nlines!", ResetUnusedStringData.ToStdString());
+}
+
+TEST(CommonFunctions, GivenStringWithNewlinesWhenResetUnusedStringIsCalledThenStringIsFormatted){
+
+ // Tests for resetting an unused string.
+
+ // Given
ResetUnusedStringData = "Some text \\nwith new \\nlines!";
+
+ // When
+
ResetUnusedString(&ResetUnusedStringData);
+
+ // Then
+
ASSERT_EQ("Some text \nwith new \nlines!", ResetUnusedStringData.ToStdString());
+
+}
+
+TEST(CommonFunctions, GivenStringWithSeveralCharactersWhenResetUnusedStringThenStringIsFormatted){
+
+ // Tests for resetting an unused string.
+
+ // Given
ResetUnusedStringData = "And now the list of characters: \\\\ \\n \\; \\,";
+
+ // When
+
ResetUnusedString(&ResetUnusedStringData);
+
+ // Then
+
ASSERT_EQ("And now the list of characters: \\ \n ; ,", ResetUnusedStringData.ToStdString());
}