OptionTest.cc 770 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "Option.h"
  2. #include <string>
  3. #include <cppunit/extensions/HelperMacros.h>
  4. using namespace std;
  5. class OptionTest:public CppUnit::TestFixture {
  6. CPPUNIT_TEST_SUITE(OptionTest);
  7. CPPUNIT_TEST(testPutAndGet);
  8. CPPUNIT_TEST(testPutAndGetAsInt);
  9. CPPUNIT_TEST_SUITE_END();
  10. private:
  11. public:
  12. void setUp() {
  13. }
  14. void testPutAndGet();
  15. void testPutAndGetAsInt();
  16. };
  17. CPPUNIT_TEST_SUITE_REGISTRATION( OptionTest );
  18. void OptionTest::testPutAndGet() {
  19. Option op;
  20. op.put("key", "value");
  21. CPPUNIT_ASSERT(op.defined("key"));
  22. CPPUNIT_ASSERT_EQUAL(string("value"), op.get("key"));
  23. }
  24. void OptionTest::testPutAndGetAsInt() {
  25. Option op;
  26. op.put("key", "1000");
  27. CPPUNIT_ASSERT(op.defined("key"));
  28. CPPUNIT_ASSERT_EQUAL(1000, op.getAsInt("key"));
  29. }