diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-03-28 15:46:49 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-03-28 15:46:49 (GMT) |
commit | f53a1ef582494458301b97bf6e546be52d7ff7e8 (patch) | |
tree | 7571b5cbcbd8a8f1dd1c966c9045b6cb69f0e295 /Swiften/Parser/UnitTest/AttributeMapTest.cpp | |
parent | 638345680d72ca6acaf123f2c8c1c391f696e371 (diff) | |
download | swift-contrib-f53a1ef582494458301b97bf6e546be52d7ff7e8.zip swift-contrib-f53a1ef582494458301b97bf6e546be52d7ff7e8.tar.bz2 |
Moving submodule contents back.
Diffstat (limited to 'Swiften/Parser/UnitTest/AttributeMapTest.cpp')
-rw-r--r-- | Swiften/Parser/UnitTest/AttributeMapTest.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Swiften/Parser/UnitTest/AttributeMapTest.cpp b/Swiften/Parser/UnitTest/AttributeMapTest.cpp new file mode 100644 index 0000000..17bda95 --- /dev/null +++ b/Swiften/Parser/UnitTest/AttributeMapTest.cpp @@ -0,0 +1,71 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +#include "Swiften/Parser/AttributeMap.h" + +using namespace Swift; + +class AttributeMapTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(AttributeMapTest); + CPPUNIT_TEST(testGetBoolAttribute_True); + CPPUNIT_TEST(testGetBoolAttribute_1); + CPPUNIT_TEST(testGetBoolAttribute_False); + CPPUNIT_TEST(testGetBoolAttribute_0); + CPPUNIT_TEST(testGetBoolAttribute_Invalid); + CPPUNIT_TEST(testGetBoolAttribute_UnknownWithDefaultTrue); + CPPUNIT_TEST(testGetBoolAttribute_UnknownWithDefaultFalse); + CPPUNIT_TEST_SUITE_END(); + + public: + AttributeMapTest() {} + + void testGetBoolAttribute_True() { + AttributeMap testling; + testling["foo"] = "true"; + + CPPUNIT_ASSERT(testling.getBoolAttribute("foo")); + } + + void testGetBoolAttribute_1() { + AttributeMap testling; + testling["foo"] = "1"; + + CPPUNIT_ASSERT(testling.getBoolAttribute("foo")); + } + + void testGetBoolAttribute_False() { + AttributeMap testling; + testling["foo"] = "false"; + + CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true)); + } + + void testGetBoolAttribute_0() { + AttributeMap testling; + testling["foo"] = "0"; + + CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true)); + } + + void testGetBoolAttribute_Invalid() { + AttributeMap testling; + testling["foo"] = "bla"; + + CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true)); + } + + void testGetBoolAttribute_UnknownWithDefaultTrue() { + AttributeMap testling; + + CPPUNIT_ASSERT(testling.getBoolAttribute("foo", true)); + } + + void testGetBoolAttribute_UnknownWithDefaultFalse() { + AttributeMap testling; + + CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", false)); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(AttributeMapTest); |