9c65af080d6c466d4ba38b5dded55ad3ef88083e
[gssweb.git] / json_gssapi / test / datamodel / GSSBufferTest.cpp
1 /*
2  * Copyright (c) 2014 <copyright holder> <email>
3  *
4  * For license details, see the LICENSE file in the root of this project.
5  *
6  */
7
8 #include "GSSBufferTest.h"
9 #include <datamodel/GSSBuffer.h>
10 #include <cstring>
11
12 CPPUNIT_TEST_SUITE_REGISTRATION( GSSBufferTest );
13
14 void
15 GSSBufferTest::setUp()
16 {
17
18 }
19
20 void
21 GSSBufferTest::tearDown()
22 {
23
24 }
25
26 void GSSBufferTest::testStringConstructor()
27 {
28     /* Variables */
29     std::string str("test string");
30     GSSBuffer buf(str);
31     gss_buffer_t gssBuf = buf.toGss();
32     
33     /* Error checking */
34     /* Setup */
35     
36     /* Main */
37     CPPUNIT_ASSERT_MESSAGE(
38         "The string was not copied in :(", 
39         (std::strncmp( (char *)str.c_str(), (char *)gssBuf->value, gssBuf->length ) == 0)
40     );
41     
42     CPPUNIT_ASSERT_EQUAL_MESSAGE(
43         "The string was not output correctly",
44         str,
45         buf.toString()
46     );
47     
48     /* Cleanup */
49     /* Return */
50 }