mirror of
https://github.com/aria2/aria2.git
synced 2025-01-24 10:41:18 +00:00
90d5b5c0a2
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.
36 lines
699 B
C++
36 lines
699 B
C++
#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
|