From dd8824ab114877000d5624a431fa92ed9af78e42 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 2 Dec 2011 00:30:11 +0900 Subject: [PATCH] Don't compare c-strng using CPPUNIT_ASSERT_EQUAL --- test/OptionParserTest.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/OptionParserTest.cc b/test/OptionParserTest.cc index ee4ce75d..727432f0 100644 --- a/test/OptionParserTest.cc +++ b/test/OptionParserTest.cc @@ -81,9 +81,9 @@ void OptionParserTest::testFindAll() { std::vector > res = oparser_->findAll(); CPPUNIT_ASSERT_EQUAL((size_t)3, res.size()); - CPPUNIT_ASSERT_EQUAL((const char*)"timeout", res[0]->getName()); - CPPUNIT_ASSERT_EQUAL((const char*)"dir", res[1]->getName()); - CPPUNIT_ASSERT_EQUAL((const char*)"out", res[2]->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("timeout"), std::string(res[0]->getName())); + CPPUNIT_ASSERT_EQUAL(std::string("dir"), std::string(res[1]->getName())); + CPPUNIT_ASSERT_EQUAL(std::string("out"), std::string(res[2]->getName())); } void OptionParserTest::testFindByNameSubstring() @@ -91,8 +91,8 @@ void OptionParserTest::testFindByNameSubstring() std::vector > res = oparser_->findByNameSubstring("i"); CPPUNIT_ASSERT_EQUAL((size_t)2, res.size()); - CPPUNIT_ASSERT_EQUAL((const char*)"timeout", res[0]->getName()); - CPPUNIT_ASSERT_EQUAL((const char*)"dir", res[1]->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("timeout"), std::string(res[0]->getName())); + CPPUNIT_ASSERT_EQUAL(std::string("dir"), std::string(res[1]->getName())); } void OptionParserTest::testFindByTag() @@ -100,15 +100,15 @@ void OptionParserTest::testFindByTag() std::vector > res = oparser_->findByTag("pineapple"); CPPUNIT_ASSERT_EQUAL((size_t)2, res.size()); - CPPUNIT_ASSERT_EQUAL((const char*)"dir", res[0]->getName()); - CPPUNIT_ASSERT_EQUAL((const char*)"out", res[1]->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("dir"), std::string(res[0]->getName())); + CPPUNIT_ASSERT_EQUAL(std::string("out"), std::string(res[1]->getName())); } void OptionParserTest::testFind() { const SharedHandle& dir = oparser_->find(PREF_DIR); CPPUNIT_ASSERT(dir); - CPPUNIT_ASSERT_EQUAL((const char*)"dir", dir->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("dir"), std::string(dir->getName())); const SharedHandle& daemon = oparser_->find(PREF_DAEMON); CPPUNIT_ASSERT(!daemon); @@ -121,7 +121,7 @@ void OptionParserTest::testFindByShortName() { const SharedHandle& timeout = oparser_->findByShortName('A'); CPPUNIT_ASSERT(timeout); - CPPUNIT_ASSERT_EQUAL((const char*)"timeout", timeout->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("timeout"), std::string(timeout->getName())); CPPUNIT_ASSERT(!oparser_->findByShortName('C')); } @@ -131,7 +131,7 @@ void OptionParserTest::testFindById() const SharedHandle& timeout = oparser_->findById(PREF_TIMEOUT->i); CPPUNIT_ASSERT(timeout); - CPPUNIT_ASSERT_EQUAL((const char*)"timeout", timeout->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("timeout"), std::string(timeout->getName())); CPPUNIT_ASSERT(!oparser_->findById(9999)); }