added test skeleton for sml_file and sml_message

This commit is contained in:
Juri Glass 2011-07-13 17:26:02 +02:00
parent aab3c3149d
commit 554b871f2f
4 changed files with 109 additions and 1 deletions

View file

@ -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

50
test/src/sml_file_test.c Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
#include "../unity/unity_fixture.h"
#include "test_helper.h"
#include <sml/sml_file.h>
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);
}

View file

@ -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 <http://www.gnu.org/licenses/>.
#include "../unity/unity_fixture.h"
#include "test_helper.h"
#include <sml/sml_message.h>
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);
}

View file

@ -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[]) {