Add tests for sanitizeDirName

This commit is contained in:
ShadowNinja 2022-01-29 22:48:41 -05:00 committed by rubenwardy
parent 00ebedad93
commit 65fdc7ae50

@ -58,6 +58,7 @@ public:
void testStringJoin(); void testStringJoin();
void testEulerConversion(); void testEulerConversion();
void testBase64(); void testBase64();
void testSanitizeDirName();
}; };
static TestUtilities g_test_instance; static TestUtilities g_test_instance;
@ -90,6 +91,7 @@ void TestUtilities::runTests(IGameDef *gamedef)
TEST(testStringJoin); TEST(testStringJoin);
TEST(testEulerConversion); TEST(testEulerConversion);
TEST(testBase64); TEST(testBase64);
TEST(testSanitizeDirName);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -630,3 +632,12 @@ void TestUtilities::testBase64()
UASSERT(base64_is_valid("AAAA=A") == false); UASSERT(base64_is_valid("AAAA=A") == false);
UASSERT(base64_is_valid("AAAAA=A") == false); UASSERT(base64_is_valid("AAAAA=A") == false);
} }
void TestUtilities::testSanitizeDirName()
{
UASSERT(sanitizeDirName("a", "_") == "a");
UASSERT(sanitizeDirName("COM1", "_") == "_COM1");
UASSERT(sanitizeDirName("cOm\u00B2 .txt:a", "_") == "cOm\u00B2 _txt_a");
UASSERT(sanitizeDirName("cOnIn$ ", "_") == "_cOnIn$ ");
}