summaryrefslogtreecommitdiffstats
blob: d89fdc5c64c75f31eb68488ae9ab56d8837c63fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>

#include "Swiften/Parser/PayloadParsers/StatusShowParser.h"
#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h"

using namespace Swift;

class StatusShowParserTest : public CppUnit::TestFixture
{
		CPPUNIT_TEST_SUITE(StatusShowParserTest);
		CPPUNIT_TEST(testParse_Invalid);
		CPPUNIT_TEST(testParse_Away);
		CPPUNIT_TEST(testParse_FFC);
		CPPUNIT_TEST(testParse_XA);
		CPPUNIT_TEST(testParse_DND);
		CPPUNIT_TEST_SUITE_END();

	public:
		StatusShowParserTest() {}

		void testParse_Invalid() {
			StatusShowParser testling;
			PayloadParserTester parser(&testling);
			
			CPPUNIT_ASSERT(parser.parse("<show>invalid</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(testling.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::Online == payload->getType());
		}

		void testParse_Away() {
			StatusShowParser testling;
			PayloadParserTester parser(&testling);
			
			CPPUNIT_ASSERT(parser.parse("<show>away</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(testling.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::Away == payload->getType());
		}

		void testParse_FFC() {
			StatusShowParser testling;
			PayloadParserTester parser(&testling);
			
			CPPUNIT_ASSERT(parser.parse("<show>chat</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(testling.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::FFC == payload->getType());
		}

		void testParse_XA() {
			StatusShowParser testling;
			PayloadParserTester parser(&testling);
			
			CPPUNIT_ASSERT(parser.parse("<show>xa</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(testling.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::XA == payload->getType());
		}

		void testParse_DND() {
			StatusShowParser testling;
			PayloadParserTester parser(&testling);
			
			CPPUNIT_ASSERT(parser.parse("<show>dnd</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(testling.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::DND == payload->getType());
		}
};

CPPUNIT_TEST_SUITE_REGISTRATION(StatusShowParserTest);