diff options
| author | Leonetienne <leonetienne@hotmail.de> | 2021-12-04 20:36:24 +0100 |
|---|---|---|
| committer | Leonetienne <leonetienne@hotmail.de> | 2021-12-04 20:36:24 +0100 |
| commit | 98c83ae9721d0018988518b531c4dd18af715483 (patch) | |
| tree | db14790cd1d0740e2a585bba4c72b3c492ff16d3 | |
| parent | 01c5cd646e18e2cc78349a4d22ae4250c971c8f3 (diff) | |
added umlaut support for Lower/Upper for îÃì
| -rw-r--r-- | StringTools/StringTools/StringTools.cpp | 6 | ||||
| -rw-r--r-- | StringTools/Test/Lower.cpp | 30 | ||||
| -rw-r--r-- | StringTools/Test/Upper.cpp | 30 |
3 files changed, 62 insertions, 4 deletions
diff --git a/StringTools/StringTools/StringTools.cpp b/StringTools/StringTools/StringTools.cpp index 4c57292..eb18c06 100644 --- a/StringTools/StringTools/StringTools.cpp +++ b/StringTools/StringTools/StringTools.cpp @@ -89,6 +89,9 @@ std::string StringTools::Lower(const std::string& str) else if (c == 'Ó') ss << 'ó';
else if (c == 'Ò') ss << 'ò';
else if (c == 'Ô') ss << 'ô';
+ else if (c == 'Í') ss << 'í';
+ else if (c == 'Ì') ss << 'ì';
+ else if (c == 'Î') ss << 'î';
// Else: keep the character as is
else ss << c;
@@ -125,6 +128,9 @@ std::string StringTools::Upper(const std::string& str) else if (c == 'ó') ss << 'Ó';
else if (c == 'ò') ss << 'Ò';
else if (c == 'ô') ss << 'Ô';
+ else if (c == 'í') ss << 'Í';
+ else if (c == 'ì') ss << 'Ì';
+ else if (c == 'î') ss << 'Î';
// Else: keep the character as is
else ss << c;
diff --git a/StringTools/Test/Lower.cpp b/StringTools/Test/Lower.cpp index c45af68..941cdb3 100644 --- a/StringTools/Test/Lower.cpp +++ b/StringTools/Test/Lower.cpp @@ -183,17 +183,43 @@ namespace _StringTools Assert::AreEqual("öóòô", out.c_str());
}
+ // Tests that lowering already lowered umlautes returns itself
+ TEST_METHOD(Umlautes_already_lower_i)
+ {
+ // Setup
+ const std::string in = "íìî";
+
+ // Exercise
+ const std::string out = StringTools::Lower(in);
+
+ // Verify
+ Assert::AreEqual("íìî", out.c_str());
+ }
+
+ // Tests that lowering uppercase umlautes returns the lowered umlautes
+ TEST_METHOD(Umlautes_upper_i)
+ {
+ // Setup
+ const std::string in = "ÍÌÎ";
+
+ // Exercise
+ const std::string out = StringTools::Lower(in);
+
+ // Verify
+ Assert::AreEqual("íìî", out.c_str());
+ }
+
// Tests that lowering a string of uppercase, lowercase letters and symbols returns the lowercase version, even with umlauts
TEST_METHOD(Mixed_with_umlautes)
{
// Setup
- const std::string in = "Ügh, Àrä Yóü Seriöûs?! DÓN'T DÒ THÄT!!!";
+ const std::string in = "Ügh, Àrä Yóü Serîöûs?! DÓN'T DÒ THÄT!!!";
// Exercise
const std::string out = StringTools::Lower(in);
// Verify
- Assert::AreEqual("ügh, àrä yóü seriöûs?! dón't dò thät!!!", out.c_str());
+ Assert::AreEqual("ügh, àrä yóü serîöûs?! dón't dò thät!!!", out.c_str());
return;
}
};
diff --git a/StringTools/Test/Upper.cpp b/StringTools/Test/Upper.cpp index cbefee7..1e7684b 100644 --- a/StringTools/Test/Upper.cpp +++ b/StringTools/Test/Upper.cpp @@ -183,17 +183,43 @@ namespace _StringTools Assert::AreEqual("ÖÓÒÔ", out.c_str());
}
+ // Tests that lowering already lowered umlautes returns itself
+ TEST_METHOD(Umlautes_already_upper_i)
+ {
+ // Setup
+ const std::string in = "ÍÌÎ";
+
+ // Exercise
+ const std::string out = StringTools::Upper(in);
+
+ // Verify
+ Assert::AreEqual("ÍÌÎ", out.c_str());
+ }
+
+ // Tests that lowering uppercase umlautes returns the lowered umlautes
+ TEST_METHOD(Umlautes_upper_i)
+ {
+ // Setup
+ const std::string in = "íìî";
+
+ // Exercise
+ const std::string out = StringTools::Upper(in);
+
+ // Verify
+ Assert::AreEqual("ÍÌÎ", out.c_str());
+ }
+
// Tests that uppering a string of uppercase, lowercase letters and symbols returns the lowercase version, even with umlauts
TEST_METHOD(Mixed_with_umlautes)
{
// Setup
- const std::string in = "Ügh, Àrä Yóü Seriöûs?! DÒN'T DÔ THÄT!!!";
+ const std::string in = "Ügh, Àrä Yóü Serîöûs?! DÒN'T DÔ THÄT!!!";
// Exercise
const std::string out = StringTools::Upper(in);
// Verify
- Assert::AreEqual("ÜGH, ÀRÄ YÓÜ SERIÖÛS?! DÒN'T DÔ THÄT!!!", out.c_str());
+ Assert::AreEqual("ÜGH, ÀRÄ YÓÜ SERÎÖÛS?! DÒN'T DÔ THÄT!!!", out.c_str());
return;
}
};
|
