server/src/util/message.test.c
Enno Rehling 47c8b20f68 add a happy test for mt_new.
refactor to not use strncpy.
2017-01-26 17:57:21 +01:00

29 lines
794 B
C

#include <platform.h>
#include "message.h"
#include <CuTest.h>
#include <tests.h>
static void test_mt_new(CuTest *tc)
{
message_type *mt;
test_setup();
mt = mt_new_va("test", "name:string", "number:int", NULL);
CuAssertPtrNotNull(tc, mt);
CuAssertStrEquals(tc, "test", mt->name);
CuAssertIntEquals(tc, 2, mt->nparameters);
CuAssertPtrNotNull(tc, mt->pnames);
CuAssertStrEquals(tc, "name", mt->pnames[0]);
CuAssertStrEquals(tc, "number", mt->pnames[1]);
CuAssertPtrNotNull(tc, mt->types);
CuAssertStrEquals(tc, "string", mt->types[0]->name);
CuAssertStrEquals(tc, "int", mt->types[1]->name);
test_cleanup();
}
CuSuite *get_message_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_mt_new);
return suite;
}