Unified the string formatting functions

This commit is contained in:
Tsuda Kageyu
2013-11-15 16:24:26 +09:00
parent 57d12de7dd
commit 116b1fcff9
5 changed files with 65 additions and 96 deletions

View File

@ -41,6 +41,7 @@ class TestString : public CppUnit::TestFixture
CPPUNIT_TEST(testAppendCharDetach);
CPPUNIT_TEST(testAppendStringDetach);
CPPUNIT_TEST(testToInt);
CPPUNIT_TEST(testFromInt);
CPPUNIT_TEST(testSubstr);
CPPUNIT_TEST(testNewline);
CPPUNIT_TEST_SUITE_END();
@ -215,6 +216,12 @@ public:
CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123);
}
void testFromInt()
{
CPPUNIT_ASSERT_EQUAL(String("123"), String::number(123));
CPPUNIT_ASSERT_EQUAL(String("-123"), String::number(-123));
}
void testSubstr()
{
CPPUNIT_ASSERT_EQUAL(String("01"), String("0123456").substr(0, 2));