Changeset View
Changeset View
Standalone View
Standalone View
source/ps/tests/test_CStr.h
/* Copyright (C) 2010 Wildfire Games. | /* Copyright (C) 2010 Wildfire Games. | ||||
elexis: 9 (can be changed when committing) | |||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
void test_parse() | void test_parse() | ||||
{ | { | ||||
// Parsing should be independent of locale ("," vs "."), | // Parsing should be independent of locale ("," vs "."), | ||||
// because GTK+ can change the locale when we're running Atlas. | // 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 | // (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) | // then it'll just stick with the default, which is fine) | ||||
char* old = setlocale(LC_NUMERIC, "fr_FR.UTF-8"); | char* old = setlocale(LC_NUMERIC, NULL); | ||||
setlocale(LC_NUMERIC, "fr_FR.UTF-8"); | |||||
CStr8 str1("1.234"); | CStr8 str1("1.234"); | ||||
TS_ASSERT_DELTA(str1.ToFloat(), 1.234f, 0.0001f); | TS_ASSERT_DELTA(str1.ToFloat(), 1.234f, 0.0001f); | ||||
TS_ASSERT_DELTA(str1.ToDouble(), 1.234, 0.0001); | TS_ASSERT_DELTA(str1.ToDouble(), 1.234, 0.0001); | ||||
TS_ASSERT_EQUALS(str1.ToInt(), 1); | TS_ASSERT_EQUALS(str1.ToInt(), 1); | ||||
TS_ASSERT_EQUALS(str1.ToUInt(), 1u); | TS_ASSERT_EQUALS(str1.ToUInt(), 1u); | ||||
TS_ASSERT_EQUALS(str1.ToLong(), 1); | TS_ASSERT_EQUALS(str1.ToLong(), 1); | ||||
TS_ASSERT_EQUALS(str1.ToULong(), 1u); | TS_ASSERT_EQUALS(str1.ToULong(), 1u); | ||||
Show All 20 Lines |
Wildfire Games · Phabricator
9 (can be changed when committing)