Add test suite for gargoyle_find_brand
This commit is contained in:
parent
224baa071b
commit
4443319f4f
5
Makefile
5
Makefile
|
@ -3,9 +3,8 @@ LDFLAGS ?= -g -O1
|
|||
LIB_CFLAGS ?= -fpic
|
||||
LIB_LDFLAGS ?= -shared
|
||||
GARGOYLE_OBJS := gargoyle scribe sleuth twine
|
||||
|
||||
# temporary until there are tests for all source files
|
||||
GARGOYLE_TEST_OBJS := runner twine
|
||||
GARGOYLE_TEST_OBJS := runner sleuth twine
|
||||
#GARGOYLE_TEST_OBJS := runner $(GARGOYLE_OBJS)
|
||||
|
||||
.PHONY: all gargoyle init docs test clean
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef GARGOYLE_TEST_SLEUTH_H_
|
||||
#define GARGOYLE_TEST_SLEUTH_H_
|
||||
|
||||
int init_suite_sleuth(void);
|
||||
int clean_suite_sleuth(void);
|
||||
void sleuth_test_find_brand(void);
|
||||
void sleuth_test_find_emblem(void);
|
||||
|
||||
#endif
|
|
@ -1,5 +1,6 @@
|
|||
#include <CUnit/Basic.h>
|
||||
#include <CUnit/TestDB.h>
|
||||
#include <gargoyle/test/sleuth.h>
|
||||
#include <gargoyle/test/twine.h>
|
||||
|
||||
int main() {
|
||||
|
@ -7,18 +8,24 @@ int main() {
|
|||
return CU_get_error();
|
||||
}
|
||||
|
||||
CU_TestInfo sleuth_tests[] = {
|
||||
{ "gargoyle_find_brand", sleuth_test_find_brand },
|
||||
// { "gargoyle_find_emblem", sleuth_test_find_emblem },
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
CU_TestInfo twine_tests[] = {
|
||||
{ "gargoyle_is_sep", twine_test_is_sep },
|
||||
{ "gargoyle_is_eql", twine_test_is_eql },
|
||||
{ "gargoyle_cmp", twine_test_cmp },
|
||||
{ "gargoyle_cpy", twine_test_cpy },
|
||||
CU_TEST_INFO_NULL,
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
CU_SuiteInfo suites[] = {
|
||||
// { "gargoyle", init_suite_gargoyle, clean_suite_gargoyle, NULL, NULL, gargoyle_tests },
|
||||
// { "scribe", init_suite_scribe, clean_suite_scribe, NULL, NULL, scribe_tests },
|
||||
// { "sleuth", init_suite_sleuth, clean_suite_sleuth, NULL, NULL, sleuth_tests },
|
||||
// { "gargoyle", init_suite_gargoyle, clean_suite_gargoyle, NULL, NULL, gargoyle_tests },
|
||||
// { "scribe", init_suite_scribe, clean_suite_scribe, NULL, NULL, scribe_tests },
|
||||
{ "sleuth", init_suite_sleuth, clean_suite_sleuth, NULL, NULL, sleuth_tests },
|
||||
{ "twine", init_suite_twine, clean_suite_twine, NULL, NULL, twine_tests },
|
||||
CU_SUITE_INFO_NULL,
|
||||
};
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#include <CUnit/Basic.h>
|
||||
#include <gargoyle/test/sleuth.h>
|
||||
#include <gargoyle/sleuth.h>
|
||||
|
||||
int init_suite_sleuth(void) {
|
||||
return CUE_SUCCESS;
|
||||
}
|
||||
|
||||
int clean_suite_sleuth(void) {
|
||||
return CUE_SUCCESS;
|
||||
}
|
||||
|
||||
void sleuth_test_find_brand(void) {
|
||||
struct gargoyle_opt optv[] = {
|
||||
{ GARGOYLE_MK_OPT("foo"), 0, NULL, 0, GARGOYLE_TYPE_BOOL },
|
||||
{ GARGOYLE_MK_OPT("bar"), 0, NULL, 0, GARGOYLE_TYPE_UINT }
|
||||
};
|
||||
|
||||
uint16_t optc = sizeof(optv) / sizeof(struct gargoyle_opt);
|
||||
|
||||
struct gargoyle_opt *opt = gargoyle_find_brand(optc, optv, "", NULL, 0, 0);
|
||||
CU_ASSERT_PTR_NULL(opt);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "foo", NULL, 0, 0);
|
||||
CU_ASSERT_PTR_NOT_NULL(opt);
|
||||
CU_ASSERT_NSTRING_EQUAL(opt->brand, "foo", opt->brand_sz);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "no-foo", NULL, 0, 0);
|
||||
CU_ASSERT_PTR_NOT_NULL(opt);
|
||||
CU_ASSERT_NSTRING_EQUAL(opt->brand, "foo", opt->brand_sz);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "no-foo", "", 0, 0);
|
||||
CU_ASSERT_PTR_NULL(opt);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "no_foo", NULL, 0, GARGOYLE_FLG_SYMBL);
|
||||
CU_ASSERT_PTR_NOT_NULL(opt);
|
||||
CU_ASSERT_NSTRING_EQUAL(opt->brand, "foo", opt->brand_sz);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "no_foo", NULL, 0, GARGOYLE_FLG_ICASE);
|
||||
CU_ASSERT_PTR_NULL(opt);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "no_foo", NULL, 0, 0);
|
||||
CU_ASSERT_PTR_NULL(opt);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "No-Foo", NULL, 0, GARGOYLE_FLG_SYMBL);
|
||||
CU_ASSERT_PTR_NULL(opt);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "No-Foo", NULL, 0, GARGOYLE_FLG_ICASE);
|
||||
CU_ASSERT_PTR_NOT_NULL(opt);
|
||||
CU_ASSERT_NSTRING_EQUAL(opt->brand, "foo", opt->brand_sz);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "No-Foo", NULL, 0, 0);
|
||||
CU_ASSERT_PTR_NULL(opt);
|
||||
|
||||
opt = gargoyle_find_brand(optc, optv, "NO_FOO", NULL, 0, GARGOYLE_FLG_FLXBL);
|
||||
CU_ASSERT_PTR_NOT_NULL(opt);
|
||||
CU_ASSERT_NSTRING_EQUAL(opt->brand, "foo", opt->brand_sz);
|
||||
}
|
||||
|
||||
void sleuth_test_find_emblem(void) {
|
||||
CU_ASSERT_TRUE(1);
|
||||
}
|
Loading…
Reference in New Issue