1
0
forked from 0ad/0ad

Revert 09916ce6cb which broken jenkins build.

This was SVN commit r22519.
This commit is contained in:
wraitii 2019-07-20 13:10:53 +00:00
parent 09916ce6cb
commit 13209c3183
3 changed files with 6 additions and 47 deletions

View File

@ -1,43 +0,0 @@
/* Copyright (C) 2019 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INCLUDED_SCOPED_LOCALE
#define INCLUDED_SCOPED_LOCALE
class ScopedLocale
{
public:
ScopedLocale(int category, char* newLocale) : m_Category(category)
{
m_OldLocale = setlocale(category, nullptr);
TS_ASSERT(setlocale(m_Category, newLocale) != nullptr);
}
~ScopedLocale()
{
TS_ASSERT(setlocale(m_Category, m_OldLocale));
}
private:
int m_Category;
char* m_OldLocale;
};
#endif // #ifndef INCLUDED_SCOPED_LOCALE

View File

@ -16,7 +16,6 @@
*/
#include "lib/self_test.h"
#include "lib/scoped_locale.h"
#include "ps/CStr.h"
@ -114,7 +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)
ScopedLocale(LC_NUMERIC, "en_US.UTF-8");
char* old = setlocale(LC_NUMERIC, "fr_FR.UTF-8");
CStr8 str1("1.234");
TS_ASSERT_DELTA(str1.ToFloat(), 1.234f, 0.0001f);
@ -139,5 +138,7 @@ public:
TS_ASSERT_EQUALS(str3.ToUInt(), 3u);
TS_ASSERT_EQUALS(str3.ToLong(), 3);
TS_ASSERT_EQUALS(str3.ToULong(), 3u);
setlocale(LC_NUMERIC, old);
}
};

View File

@ -16,7 +16,6 @@
*/
#include "lib/self_test.h"
#include "lib/scoped_locale.h"
#include "third_party/cppformat/format.h"
@ -26,7 +25,7 @@ public:
void test_basic()
{
// Make test behave independent of current host locale
ScopedLocale(LC_ALL, "en_US.UTF-8");
char* old = setlocale(LC_ALL, "en_US.UTF-8");
TS_ASSERT_EQUALS(fmt::sprintf("abc"), "abc");
@ -58,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);
}
};