added umlaut support for Lower/Upper for îíì

This commit is contained in:
Leonetienne 2021-12-04 20:36:24 +01:00
parent 01c5cd646e
commit 98c83ae972
3 changed files with 66 additions and 8 deletions

View File

@ -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 if (c == 'Í') ss << 'í';
else if (c == 'Ì') ss << 'ì';
else if (c == 'Î') ss << 'î';
// Else: keep the character as is // Else: keep the character as is
else ss << c; 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 if (c == 'í') ss << 'Í';
else if (c == 'ì') ss << 'Ì';
else if (c == 'î') ss << 'Î';
// Else: keep the character as is // Else: keep the character as is
else ss << c; else ss << c;

View File

@ -183,17 +183,43 @@ namespace _StringTools
Assert::AreEqual("öóòô", out.c_str()); Assert::AreEqual("öóòô", out.c_str());
} }
// Tests that lowering a string of uppercase, lowercase letters and symbols returns the lowercase version, even with umlauts // Tests that lowering already lowered umlautes returns itself
TEST_METHOD(Mixed_with_umlautes) TEST_METHOD(Umlautes_already_lower_i)
{ {
// Setup // Setup
const std::string in = "Ügh, Àrä Yóü Seriöûs?! DÓN'T DÒ THÄT!!!"; const std::string in = "íìî";
// Exercise // Exercise
const std::string out = StringTools::Lower(in); const std::string out = StringTools::Lower(in);
// Verify // Verify
Assert::AreEqual("ügh, àrä yóü seriöûs?! dón't dò thät!!!", out.c_str()); 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óü Serîöûs?! DÓN'T DÒ THÄT!!!";
// Exercise
const std::string out = StringTools::Lower(in);
// Verify
Assert::AreEqual("ügh, àrä yóü serîöûs?! dón't dò thät!!!", out.c_str());
return; return;
} }
}; };

View File

@ -183,17 +183,43 @@ namespace _StringTools
Assert::AreEqual("钟以", out.c_str()); Assert::AreEqual("钟以", out.c_str());
} }
// Tests that uppering a string of uppercase, lowercase letters and symbols returns the lowercase version, even with umlauts // Tests that lowering already lowered umlautes returns itself
TEST_METHOD(Mixed_with_umlautes) TEST_METHOD(Umlautes_already_upper_i)
{ {
// Setup // Setup
const std::string in = "Ügh, Àrä Yóü Seriöûs?! DÒN'T DÔ THÄT!!!"; const std::string in = "ÍÌÎ";
// Exercise // Exercise
const std::string out = StringTools::Upper(in); const std::string out = StringTools::Upper(in);
// Verify // Verify
Assert::AreEqual("ÜGH, ÀRÄ YÓÜ SERIÖÛS?! DÒN'T DÔ THÄT!!!", out.c_str()); 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óü Serîöûs?! DÒN'T DÔ THÄT!!!";
// Exercise
const std::string out = StringTools::Upper(in);
// Verify
Assert::AreEqual("ÜGH, ÀRÄ YÓÜ SERÎÖÛS?! DÒN'T DÔ THÄT!!!", out.c_str());
return; return;
} }
}; };