summaryrefslogtreecommitdiffstats
blob: da9287a4f6e4033fc4c1b1e930463d42566b95b4 (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
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>

#include "Swiften/SASL/PLAINMessage.h"

using namespace Swift;

class PLAINMessageTest : public CppUnit::TestFixture
{
		CPPUNIT_TEST_SUITE(PLAINMessageTest);
		CPPUNIT_TEST(testConstructor_WithoutAuthzID);
		CPPUNIT_TEST(testConstructor_WithAuthzID);
		CPPUNIT_TEST_SUITE_END();

	public:
		PLAINMessageTest() {}

		void testConstructor_WithoutAuthzID() {
			PLAINMessage message("user", "pass");
			CPPUNIT_ASSERT_EQUAL(message.getValue(), ByteArray("\0user\0pass", 10));
		}

		void testConstructor_WithAuthzID() {
			PLAINMessage message("user", "pass", "authz");
			CPPUNIT_ASSERT_EQUAL(message.getValue(), ByteArray("authz\0user\0pass", 15));
		}
};

CPPUNIT_TEST_SUITE_REGISTRATION(PLAINMessageTest);