2006-02-17 13:35:04 +00:00
|
|
|
#include "Option.h"
|
|
|
|
#include <string>
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class OptionTest:public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(OptionTest);
|
|
|
|
CPPUNIT_TEST(testPutAndGet);
|
|
|
|
CPPUNIT_TEST(testPutAndGetAsInt);
|
2006-08-28 12:40:41 +00:00
|
|
|
CPPUNIT_TEST(testPutAndGetAsDouble);
|
2006-02-17 13:35:04 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
private:
|
|
|
|
|
|
|
|
public:
|
|
|
|
void setUp() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void testPutAndGet();
|
|
|
|
void testPutAndGetAsInt();
|
2006-08-28 12:40:41 +00:00
|
|
|
void testPutAndGetAsDouble();
|
2006-02-17 13:35:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( OptionTest );
|
|
|
|
|
|
|
|
void OptionTest::testPutAndGet() {
|
|
|
|
Option op;
|
|
|
|
op.put("key", "value");
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT(op.defined("key"));
|
|
|
|
CPPUNIT_ASSERT_EQUAL(string("value"), op.get("key"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionTest::testPutAndGetAsInt() {
|
|
|
|
Option op;
|
|
|
|
op.put("key", "1000");
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT(op.defined("key"));
|
2007-08-15 15:11:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int32_t)1000, op.getAsInt("key"));
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
2006-08-28 12:40:41 +00:00
|
|
|
|
|
|
|
void OptionTest::testPutAndGetAsDouble() {
|
|
|
|
Option op;
|
|
|
|
op.put("key", "10.0");
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(10.0, op.getAsDouble("key"));
|
|
|
|
}
|