mirror of https://github.com/aria2/aria2
2009-06-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added unit tests for strjoin, strconcat and strappend. * test/a2functionalTest.ccpull/1/head
parent
9be97eebb5
commit
b345f76607
|
@ -1,3 +1,8 @@
|
||||||
|
2009-06-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added unit tests for strjoin, strconcat and strappend.
|
||||||
|
* test/a2functionalTest.cc
|
||||||
|
|
||||||
2009-06-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-06-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Rewritten strconcat and strappend using operator+ instead of
|
Rewritten strconcat and strappend using operator+ instead of
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
|
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -10,10 +12,16 @@ class a2functionalTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST_SUITE(a2functionalTest);
|
CPPUNIT_TEST_SUITE(a2functionalTest);
|
||||||
CPPUNIT_TEST(testMemFunSh);
|
CPPUNIT_TEST(testMemFunSh);
|
||||||
CPPUNIT_TEST(testAdopt2nd);
|
CPPUNIT_TEST(testAdopt2nd);
|
||||||
|
CPPUNIT_TEST(testStrjoin);
|
||||||
|
CPPUNIT_TEST(testStrconcat);
|
||||||
|
CPPUNIT_TEST(testStrappend);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
public:
|
public:
|
||||||
void testMemFunSh();
|
void testMemFunSh();
|
||||||
void testAdopt2nd();
|
void testAdopt2nd();
|
||||||
|
void testStrjoin();
|
||||||
|
void testStrconcat();
|
||||||
|
void testStrappend();
|
||||||
|
|
||||||
class Greeting {
|
class Greeting {
|
||||||
public:
|
public:
|
||||||
|
@ -63,4 +71,33 @@ void a2functionalTest::testAdopt2nd()
|
||||||
adopt2nd(std::plus<std::string>(), mem_fun_sh(&Greeting::sayGreeting))("A Japanese said:", greeting));
|
adopt2nd(std::plus<std::string>(), mem_fun_sh(&Greeting::sayGreeting))("A Japanese said:", greeting));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void a2functionalTest::testStrjoin()
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string(""), strjoin(v.begin(), v.end(), " "));
|
||||||
|
|
||||||
|
v.push_back("A");
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("A"), strjoin(v.begin(), v.end(), " "));
|
||||||
|
|
||||||
|
v.push_back("hero");
|
||||||
|
v.push_back("is");
|
||||||
|
v.push_back("lonely");
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("A hero is lonely"),
|
||||||
|
strjoin(v.begin(), v.end(), " "));
|
||||||
|
}
|
||||||
|
|
||||||
|
void a2functionalTest::testStrconcat()
|
||||||
|
{
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("X=3"), strconcat("X=", "3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void a2functionalTest::testStrappend()
|
||||||
|
{
|
||||||
|
std::string str = "X=";
|
||||||
|
strappend(str, "3", ",Y=", "5");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("X=3,Y=5"), str);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
Loading…
Reference in New Issue