summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-09-11 20:08:45 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-09-14 10:42:17 (GMT)
commit234b140b5675c737859ed2457dcb07ad75a900ab (patch)
tree9078086da49cbbf9e2c45048f69e75d736030311 /Swiften/Parser/UnitTest
parent811f6857563401636ba5ea39fc63892eacf007cd (diff)
downloadswift-contrib-234b140b5675c737859ed2457dcb07ad75a900ab.zip
swift-contrib-234b140b5675c737859ed2457dcb07ad75a900ab.tar.bz2
Added bookmark storage payload & parser.
Diffstat (limited to 'Swiften/Parser/UnitTest')
-rw-r--r--Swiften/Parser/UnitTest/AttributeMapTest.cpp71
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);