Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/tests/test_cppformat.h
Show All 18 Lines | |||||
#include "third_party/cppformat/format.h" | #include "third_party/cppformat/format.h" | ||||
class TestCppformat : public CxxTest::TestSuite | class TestCppformat : public CxxTest::TestSuite | ||||
{ | { | ||||
public: | public: | ||||
void test_basic() | 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("abc"), "abc"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("%d", 123), "123"); | TS_ASSERT_EQUALS(fmt::sprintf("%d", 123), "123"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("%d", (int64_t)123), "123"); | TS_ASSERT_EQUALS(fmt::sprintf("%d", (int64_t)123), "123"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("%i", 123), "123"); | TS_ASSERT_EQUALS(fmt::sprintf("%i", 123), "123"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("%04x", 123), "007b"); | TS_ASSERT_EQUALS(fmt::sprintf("%04x", 123), "007b"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("%04X", 123), "007B"); | TS_ASSERT_EQUALS(fmt::sprintf("%04X", 123), "007B"); | ||||
Show All 14 Lines | void test_basic() | ||||
TS_ASSERT_EQUALS(fmt::sprintf("T%sT", "abc"), "TabcT"); | TS_ASSERT_EQUALS(fmt::sprintf("T%sT", "abc"), "TabcT"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("T%sT", std::string("abc")), "TabcT"); | TS_ASSERT_EQUALS(fmt::sprintf("T%sT", std::string("abc")), "TabcT"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("T%sT", CStr("abc")), "TabcT"); | TS_ASSERT_EQUALS(fmt::sprintf("T%sT", CStr("abc")), "TabcT"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("T%sT", (const char*)NULL), "T(null)T"); | TS_ASSERT_EQUALS(fmt::sprintf("T%sT", (const char*)NULL), "T(null)T"); | ||||
TS_ASSERT_EQUALS(fmt::sprintf("T%pT", (void*)0x1234), "T0x1234T"); | TS_ASSERT_EQUALS(fmt::sprintf("T%pT", (void*)0x1234), "T0x1234T"); | ||||
setlocale(LC_ALL, old); | |||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator