From 61db02790c6c8d856fe1f047cb7c442a517ef8c6 Mon Sep 17 00:00:00 2001 From: wraitii Date: Sun, 16 Jun 2019 15:25:17 +0000 Subject: [PATCH] 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. --- source/ps/tests/test_CStr.h | 3 +-- source/ps/tests/test_cppformat.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/ps/tests/test_CStr.h b/source/ps/tests/test_CStr.h index 317f8e62f4..4e7562ec20 100644 --- a/source/ps/tests/test_CStr.h +++ b/source/ps/tests/test_CStr.h @@ -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); diff --git a/source/ps/tests/test_cppformat.h b/source/ps/tests/test_cppformat.h index 02d0193694..df2e2f8380 100644 --- a/source/ps/tests/test_cppformat.h +++ b/source/ps/tests/test_cppformat.h @@ -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); } };