1
0
forked from 0ad/0ad

Fix cppformat failures on MacOS tests.

cppformat tests failed on MacOS - the global locale was not set and
defaulted to something unexcpeted.
It is now fixed to US notation.

Patch By: Krinkle
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1978
This was SVN commit r22378.
This commit is contained in:
wraitii 2019-06-16 15:25:17 +00:00
parent 9e8a43401e
commit 61db02790c
2 changed files with 6 additions and 2 deletions

View File

@ -113,8 +113,7 @@ public:
// because GTK+ can change the locale when we're running Atlas.
// (If the host system doesn't have the locale we're using for this test
// then it'll just stick with the default, which is fine)
char* old = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "fr_FR.UTF-8");
char* old = setlocale(LC_NUMERIC, "fr_FR.UTF-8");
CStr8 str1("1.234");
TS_ASSERT_DELTA(str1.ToFloat(), 1.234f, 0.0001f);

View File

@ -24,6 +24,9 @@ class TestCppformat : public CxxTest::TestSuite
public:
void test_basic()
{
// Make test behave independent of current host locale
char* old = setlocale(LC_ALL, "en_US.UTF-8");
TS_ASSERT_EQUALS(fmt::sprintf("abc"), "abc");
TS_ASSERT_EQUALS(fmt::sprintf("%d", 123), "123");
@ -54,5 +57,7 @@ public:
TS_ASSERT_EQUALS(fmt::sprintf("T%sT", (const char*)NULL), "T(null)T");
TS_ASSERT_EQUALS(fmt::sprintf("T%pT", (void*)0x1234), "T0x1234T");
setlocale(LC_ALL, old);
}
};