new tests for string exceptions

master
Marc Wäckerlin 20 years ago
parent a5c5b70eed
commit 0a3a928547
  1. 18
      mrw/stdext_test.cpp

@ -9,6 +9,9 @@
@license LGPL, see file <a href="license.html">COPYING</a> @license LGPL, see file <a href="license.html">COPYING</a>
$Log$ $Log$
Revision 1.3 2004/12/20 13:23:00 marc
new tests for string exceptions
Revision 1.2 2004/10/13 11:19:22 marc Revision 1.2 2004/10/13 11:19:22 marc
remove stdout, print stack trace remove stdout, print stack trace
@ -50,11 +53,9 @@ public:
CPPUNIT_ASSERT(i2==45); CPPUNIT_ASSERT(i2==45);
CPPUNIT_ASSERT(s==" xx"); CPPUNIT_ASSERT(s==" xx");
s2=""; s3=""; s2=""; s3="";
s>>s2>>s3; s>>s2;
CPPUNIT_ASSERT(s2=="xx"); CPPUNIT_ASSERT(s2=="xx");
CPPUNIT_ASSERT(s3=="");
CPPUNIT_ASSERT(s==""); CPPUNIT_ASSERT(s=="");
} }
void StringAdd() { void StringAdd() {
std::string s; std::string s;
@ -232,6 +233,15 @@ public:
} }
CPPUNIT_ASSERT(exc); CPPUNIT_ASSERT(exc);
} }
void StringException1() {
std::string s("Hello World");
int hello;
s>>hello; // not an int, exception expected
}
void StringException2() {
std::string s("Hello World");
mrw::to<int>(s); // not an int, exception expected
}
CPPUNIT_TEST_SUITE(StdExtTest); CPPUNIT_TEST_SUITE(StdExtTest);
CPPUNIT_TEST(StringConv); CPPUNIT_TEST(StringConv);
CPPUNIT_TEST(StringShift); CPPUNIT_TEST(StringShift);
@ -243,6 +253,8 @@ public:
CPPUNIT_TEST(MapShift); CPPUNIT_TEST(MapShift);
CPPUNIT_TEST(MultisetShift); CPPUNIT_TEST(MultisetShift);
CPPUNIT_TEST(MultimapShift); CPPUNIT_TEST(MultimapShift);
CPPUNIT_TEST_EXCEPTION(StringException1, mrw::invalid_argument);
CPPUNIT_TEST_EXCEPTION(StringException2, mrw::invalid_argument);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
CPPUNIT_TEST_SUITE_REGISTRATION(StdExtTest); CPPUNIT_TEST_SUITE_REGISTRATION(StdExtTest);

Loading…
Cancel
Save