From 554b871f2fb20a6ed8718d279fa8c70b1f0bb0e6 Mon Sep 17 00:00:00 2001 From: Juri Glass Date: Wed, 13 Jul 2011 17:26:02 +0200 Subject: [PATCH] added test skeleton for sml_file and sml_message --- test/Makefile | 4 ++- test/src/sml_file_test.c | 50 ++++++++++++++++++++++++++++++++++ test/src/sml_message_test.c | 54 +++++++++++++++++++++++++++++++++++++ test/test_main.c | 2 ++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 test/src/sml_file_test.c create mode 100644 test/src/sml_message_test.c diff --git a/test/Makefile b/test/Makefile index 9f67152..c060926 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,7 +10,9 @@ OBJS = \ src/sml_octet_string_test.o \ src/sml_buffer_test.o \ src/sml_number_test.o \ - src/sml_boolean_test.o + src/sml_boolean_test.o \ + src/sml_file_test.o \ + src/sml_message_test.o test_run: libsml test @./test diff --git a/test/src/sml_file_test.c b/test/src/sml_file_test.c new file mode 100644 index 0000000..7f135c5 --- /dev/null +++ b/test/src/sml_file_test.c @@ -0,0 +1,50 @@ +// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed +// DAI-Labor, TU-Berlin +// +// This file is part of libSML. +// +// libSML is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libSML is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libSML. If not, see . + +#include "../unity/unity_fixture.h" +#include "test_helper.h" +#include + +TEST_GROUP(sml_file); + +sml_buffer *buf; + +TEST_SETUP(sml_file) { + buf = sml_buffer_init(512); +} + +TEST_TEAR_DOWN(sml_file) { + sml_buffer_free(buf); +} + +TEST(sml_file, init) { + sml_file *file = sml_file_init(); + TEST_ASSERT_NOT_NULL(file); + TEST_ASSERT_EQUAL(0, file->messages_len); + TEST_ASSERT_NULL(file->messages); + TEST_ASSERT_NOT_NULL(file->buf); +} + + +TEST_GROUP_RUNNER(sml_file) { + RUN_TEST_CASE(sml_file, init); +} + + + + diff --git a/test/src/sml_message_test.c b/test/src/sml_message_test.c new file mode 100644 index 0000000..dc2b5ba --- /dev/null +++ b/test/src/sml_message_test.c @@ -0,0 +1,54 @@ +// Copyright 2011 Juri Glass, Mathias Runge, Nadim El Sayed +// DAI-Labor, TU-Berlin +// +// This file is part of libSML. +// +// libSML is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// libSML is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with libSML. If not, see . + +#include "../unity/unity_fixture.h" +#include "test_helper.h" +#include + +TEST_GROUP(sml_message); + +sml_buffer *buf; + +TEST_SETUP(sml_message) { + buf = sml_buffer_init(512); +} + +TEST_TEAR_DOWN(sml_message) { + sml_buffer_free(buf); +} + +TEST(sml_message, init) { + sml_message *msg = sml_message_init(); + TEST_ASSERT_NOT_NULL(msg); + TEST_ASSERT_NOT_NULL(msg->transaction_id); +} + +TEST(sml_message, init_unique_transaction_id) { + sml_message *msg1 = sml_message_init(); + sml_message *msg2 = sml_message_init(); + TEST_ASSERT_TRUE(sml_octet_string_cmp(msg1->transaction_id, msg2->transaction_id) != 0); +} + +TEST_GROUP_RUNNER(sml_message) { + RUN_TEST_CASE(sml_message, init); + RUN_TEST_CASE(sml_message, init_unique_transaction_id); +} + + + + diff --git a/test/test_main.c b/test/test_main.c index c237572..23d52d1 100644 --- a/test/test_main.c +++ b/test/test_main.c @@ -23,6 +23,8 @@ static void runAllTests() { RUN_TEST_GROUP(sml_buffer); RUN_TEST_GROUP(sml_number); RUN_TEST_GROUP(sml_boolean); + RUN_TEST_GROUP(sml_message); + RUN_TEST_GROUP(sml_file); } int main(int argc, char * argv[]) {