1 // Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed
2 // DAI-Labor, TU-Berlin
3 //
4 // This file is part of libSML.
5 //
6 // libSML is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // libSML is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with libSML.  If not, see <http://www.gnu.org/licenses/>.
18 
19 #include "../unity/unity_fixture.h"
20 #include "test_helper.h"
21 #include <sml/sml_message.h>
22 
23 TEST_GROUP(sml_message);
24 
25 extern sml_buffer *buf;
26 
TEST_SETUP(sml_message)27 TEST_SETUP(sml_message) {
28 	buf = sml_buffer_init(512);
29 }
30 
TEST_TEAR_DOWN(sml_message)31 TEST_TEAR_DOWN(sml_message) {
32 	sml_buffer_free(buf);
33 }
34 
TEST(sml_message,init)35 TEST(sml_message, init) {
36 	sml_message *msg = sml_message_init();
37 	TEST_ASSERT_NOT_NULL(msg);
38 	TEST_ASSERT_NOT_NULL(msg->transaction_id);
39 	sml_message_free( msg );
40 }
41 
TEST(sml_message,init_unique_transaction_id)42 TEST(sml_message, init_unique_transaction_id) {
43 	sml_message *msg1 = sml_message_init();
44 	sml_message *msg2 = sml_message_init();
45 	TEST_ASSERT_TRUE(sml_octet_string_cmp(msg1->transaction_id, msg2->transaction_id) != 0);
46 	sml_message_free( msg2 );
47 	sml_message_free( msg1 );
48 }
49 
TEST(sml_message,parse)50 TEST(sml_message, parse) {
51 	hex2binary("7607003800003FB662006200726301017601010700380042153D0B06454D48010271533BCD010163820800", sml_buf_get_current_buf(buf));
52 	sml_message *msg = sml_message_parse(buf);
53 	TEST_ASSERT_NOT_NULL(msg);
54 	sml_message_free( msg );
55 }
56 
TEST_GROUP_RUNNER(sml_message)57 TEST_GROUP_RUNNER(sml_message) {
58 	RUN_TEST_CASE(sml_message, init);
59 	RUN_TEST_CASE(sml_message, init_unique_transaction_id);
60 	RUN_TEST_CASE(sml_message, parse);
61 }
62 
63