From 90d5b5c0a268e145cd121a0bcf2bdc0b624f0ca3 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 26 Apr 2008 05:58:49 +0000 Subject: 2008-04-26 Tatsuhiro Tsujikawa Added StringFormat class, which internally calls vasprintf. operator<< is defined for this class, so it can be used with iostream classes nicely. SimpleLogger and following functions are rewritten using StringFormat class. Besides, now Logger class's methods are non-const, many classes that has a const Logger* as a member variable are modified to remove const qualifier from the variable declaration. * src/HelpItemFactory.cc * src/Request.cc * src/SimpleLogger.cc * src/StringFormat.cc * src/StringFormat.h * src/Util.cc * src/option_processing.cc * src/version_usage.cc * test/StringFormatTest.cc * src/*.h: The classes that has const Logger* as a member variable. --- test/StringFormatTest.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/StringFormatTest.cc (limited to 'test/StringFormatTest.cc') diff --git a/test/StringFormatTest.cc b/test/StringFormatTest.cc new file mode 100644 index 00000000..642836a5 --- /dev/null +++ b/test/StringFormatTest.cc @@ -0,0 +1,35 @@ +#include "StringFormat.h" +#include "Exception.h" +#include "Util.h" +#include +#include + +namespace aria2 { + +class StringFormatTest:public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(StringFormatTest); + CPPUNIT_TEST(testGetString); + CPPUNIT_TEST_SUITE_END(); +public: + void setUp() {} + + void tearDown() {} + + void testGetString(); +}; + + +CPPUNIT_TEST_SUITE_REGISTRATION(StringFormatTest); + +void StringFormatTest::testGetString() +{ + int major = 1; + int minor = 0; + int release = 7; + StringFormat fmt("aria2-%d.%d.%d-%s", major, minor, release, "beta"); + + CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.7-beta"), fmt.toString()); +} + +} // namespace aria2 -- cgit