fixed a lot of issues, now successfully runs the test with --enable-pedantic; refs #8
This commit is contained in:
@@ -40,30 +40,32 @@ class StdExtTest: public CppUnit::TestFixture {
|
||||
public:
|
||||
void StringConv() {
|
||||
std::string s("Integer=");
|
||||
int i(4);
|
||||
CPPUNIT_ASSERT(s+mrw::string(i) == "Integer=4");
|
||||
int i(-7382);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Integer=-7382"), s+mrw::string(i));
|
||||
CPPUNIT_ASSERT_EQUAL(i, mrw::to<int>(mrw::string(i)));
|
||||
}
|
||||
void StringShift() {
|
||||
std::string s("Integer=");
|
||||
int i(4);
|
||||
CPPUNIT_ASSERT((s<<i<<" test "<<4<<(long)5<<" xx") == "Integer=4 test 45 xx");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Integer=4 test 45 xx"),
|
||||
(s<<i<<" test "<<4<<(long)5<<" xx"));
|
||||
int i2 = 0;
|
||||
std::string s2, s3;
|
||||
s>>s2>>s3>>i2;
|
||||
CPPUNIT_ASSERT(s2=="Integer=4");
|
||||
CPPUNIT_ASSERT(s3=="test");
|
||||
CPPUNIT_ASSERT(i2==45);
|
||||
CPPUNIT_ASSERT(s==" xx");
|
||||
CPPUNIT_ASSERT_NO_THROW(s>>s2>>s3>>i2);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Integer=4"), s2);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("test"), s3);
|
||||
CPPUNIT_ASSERT_EQUAL(45, i2);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(" xx"), s);
|
||||
s2=""; s3="";
|
||||
s>>s2;
|
||||
CPPUNIT_ASSERT(s2=="xx");
|
||||
CPPUNIT_ASSERT(s=="");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("xx"), s2);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(), s);
|
||||
}
|
||||
void StringAdd() {
|
||||
std::string s;
|
||||
s=s+(signed short)1+(signed int)2+(signed long)3+(signed char)'A'+
|
||||
(unsigned short)1+(unsigned int)2+(unsigned long)3+(unsigned char)'A'+'c';
|
||||
CPPUNIT_ASSERT(s=="1236512365c");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("1236512365c"), s);
|
||||
s=(signed short)-4+s;
|
||||
s=(signed int)5+s;
|
||||
s=(signed long)6+s;
|
||||
@@ -73,7 +75,7 @@ public:
|
||||
s=(unsigned long)6+s;
|
||||
s=(unsigned char)8+s;
|
||||
s='a'+s;
|
||||
CPPUNIT_ASSERT(s=="a8654865-41236512365c");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("a8654865-41236512365c"), s);
|
||||
s+=(signed short)-4;
|
||||
s+=(signed int)5 ;
|
||||
s+=(signed long)6;
|
||||
@@ -83,7 +85,7 @@ public:
|
||||
s+=(unsigned long)6;
|
||||
s+=(unsigned char)8 ;
|
||||
s+='a';
|
||||
CPPUNIT_ASSERT(s=="a8654865-41236512365c-45684568a");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("a8654865-41236512365c-45684568a"), s);
|
||||
}
|
||||
void ListShift() {
|
||||
std::list<int> l;
|
||||
@@ -92,9 +94,9 @@ public:
|
||||
l>>i1>>i2>>i3>>i4;
|
||||
// now: i1==1 i2==2 i3==3 i4==4 l=={5, 6, 7, 8}
|
||||
CPPUNIT_ASSERT(i1==1 && i2==2 && i3==3 && i4==4);
|
||||
CPPUNIT_ASSERT(l.size()==4);
|
||||
CPPUNIT_ASSERT_EQUAL(std::list<int>::size_type(4), l.size());
|
||||
for (int i=0; i<4; (l.pop_front(), ++i)) {
|
||||
CPPUNIT_ASSERT(l.front()==i+5);
|
||||
CPPUNIT_ASSERT_EQUAL(i+5, l.front());
|
||||
}
|
||||
bool exc(false);
|
||||
try {
|
||||
@@ -106,9 +108,11 @@ public:
|
||||
}
|
||||
void VectorShift() {
|
||||
std::vector<int> l;
|
||||
l<<1<<2<<3<<4<<5<<6<<7<<8;
|
||||
CPPUNIT_ASSERT_NO_THROW(l<<1<<2<<3<<4<<5<<6<<7<<8);
|
||||
CPPUNIT_ASSERT_EQUAL(std::vector<int>::size_type(8), l.size());
|
||||
int i1(0), i2(0), i3(0), i4(0);
|
||||
l>>i1>>i2>>i3>>i4;
|
||||
CPPUNIT_ASSERT_NO_THROW(l>>i1>>i2>>i3>>i4);
|
||||
CPPUNIT_ASSERT_EQUAL(std::vector<int>::size_type(4), l.size());
|
||||
// now: i1==1 i2==2 i3==3 i4==4 l=={5, 6, 7, 8}
|
||||
CPPUNIT_ASSERT(i1==1 && i2==2 && i3==3 && i4==4);
|
||||
CPPUNIT_ASSERT(l.size()==4);
|
||||
@@ -125,14 +129,14 @@ public:
|
||||
}
|
||||
void DequeShift() {
|
||||
std::deque<int> l;
|
||||
l<<1<<2<<3<<4<<5<<6<<7<<8;
|
||||
CPPUNIT_ASSERT_NO_THROW(l<<1<<2<<3<<4<<5<<6<<7<<8);
|
||||
int i1(0), i2(0), i3(0), i4(0);
|
||||
l>>i1>>i2>>i3>>i4;
|
||||
CPPUNIT_ASSERT_NO_THROW(l>>i1>>i2>>i3>>i4);
|
||||
// now: i1==1 i2==2 i3==3 i4==4 l=={5, 6, 7, 8}
|
||||
CPPUNIT_ASSERT(i1==1 && i2==2 && i3==3 && i4==4);
|
||||
CPPUNIT_ASSERT(l.size()==4);
|
||||
CPPUNIT_ASSERT_EQUAL(std::deque<int>::size_type(4), l.size());
|
||||
for (int i=0; i<4; (l.erase(l.begin()), ++i)) {
|
||||
CPPUNIT_ASSERT(l.front()==i+5);
|
||||
CPPUNIT_ASSERT_EQUAL(i+5, l.front());
|
||||
}
|
||||
bool exc(false);
|
||||
try {
|
||||
@@ -156,7 +160,7 @@ public:
|
||||
s>>i1>>i2>>i3>>i4;
|
||||
// now: i1==1 i2==2 i3==3 i4==4 s=={5, 6, 7, 8}
|
||||
CPPUNIT_ASSERT(i1==1 && i2==2 && i3==3 && i4==4);
|
||||
CPPUNIT_ASSERT(s.size()==4);
|
||||
CPPUNIT_ASSERT_EQUAL(std::set<int>::size_type(4), s.size());
|
||||
for (int i=0; i<4; ++i) {
|
||||
CPPUNIT_ASSERT(s.find(i+5)!=s.end());
|
||||
}
|
||||
@@ -170,7 +174,8 @@ public:
|
||||
CPPUNIT_ASSERT(exc);
|
||||
}
|
||||
void MapShift() {
|
||||
std::map<int, std::string> s;
|
||||
typedef std::map<int, std::string> Map;
|
||||
Map s;
|
||||
bool exc(false);
|
||||
try {
|
||||
s<<std::make_pair(1, std::string("one"))
|
||||
@@ -185,7 +190,7 @@ public:
|
||||
// now: i1==1 i2==2 i3==3 i4==4 s=={5, 6, 7, 8}
|
||||
CPPUNIT_ASSERT(i1==std::make_pair(1, std::string("one")) &&
|
||||
i2==std::make_pair(2, std::string("two")));
|
||||
CPPUNIT_ASSERT(s.size()==0);
|
||||
CPPUNIT_ASSERT_EQUAL(Map::size_type(0), s.size());
|
||||
exc=false;
|
||||
try {
|
||||
s>>i1;
|
||||
@@ -201,7 +206,7 @@ public:
|
||||
s>>i1>>i2>>i3>>i4;
|
||||
// now: i1==1 i2==2 i3==3 i4==4 s=={5, 6, 7, 8}
|
||||
CPPUNIT_ASSERT(i1==1 && i2==2 && i3==3 && i4==4);
|
||||
CPPUNIT_ASSERT(s.size()==5);
|
||||
CPPUNIT_ASSERT_EQUAL(std::multiset<int>::size_type(5), s.size());
|
||||
for (int i=0; i<5; ++i) {
|
||||
CPPUNIT_ASSERT(s.find(i+5)!=s.end());
|
||||
}
|
||||
@@ -215,7 +220,8 @@ public:
|
||||
CPPUNIT_ASSERT(exc);
|
||||
}
|
||||
void MultimapShift() {
|
||||
std::multimap<int, std::string> s;
|
||||
typedef std::multimap<int, std::string> Map;
|
||||
Map s;
|
||||
s<<std::make_pair(1, std::string("one"))
|
||||
<<std::make_pair(2, std::string("two"))
|
||||
<<std::make_pair(2, std::string("two"));
|
||||
@@ -224,9 +230,9 @@ public:
|
||||
// now: i1==1 i2==2 i3==3 i4==4 s=={5, 6, 7, 8}
|
||||
CPPUNIT_ASSERT(i1==std::make_pair(1, std::string("one")) &&
|
||||
i2==std::make_pair(2, std::string("two")));
|
||||
CPPUNIT_ASSERT(s.size()==1);
|
||||
CPPUNIT_ASSERT_EQUAL(Map::size_type(1), s.size());
|
||||
s>>i1;
|
||||
CPPUNIT_ASSERT(i1==std::make_pair(2, std::string("two")));
|
||||
CPPUNIT_ASSERT(std::make_pair(2, std::string("two"))==i1);
|
||||
bool exc(false);
|
||||
try {
|
||||
s>>i1;
|
||||
|
Reference in New Issue
Block a user