summaryrefslogtreecommitdiff
path: root/test/StringFormatTest.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-04-26 05:58:49 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-04-26 05:58:49 +0000
commit90d5b5c0a268e145cd121a0bcf2bdc0b624f0ca3 (patch)
tree913532d3875403d87d38037dcca0e15c3fed539c /test/StringFormatTest.cc
parent0f92203ffebb18f754cffecc06dcb2bea2189594 (diff)
2008-04-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
Diffstat (limited to 'test/StringFormatTest.cc')
-rw-r--r--test/StringFormatTest.cc35
1 files changed, 35 insertions, 0 deletions
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 <iostream>
+#include <cppunit/extensions/HelperMacros.h>
+
+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