132 lines
4.5 KiB
C
132 lines
4.5 KiB
C
#include <CUnit/Basic.h>
|
|
#include <gargoyle/sleuth.h>
|
|
#include <gargoyle/test/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_optn optv[] = {
|
|
{ GARGOYLE_MK_OPTN("baz"), 0, "no-", 3, GARGOYLE_TYPE_DBLE },
|
|
{ GARGOYLE_MK_OPTN("foo"), 0, "no-", 3, GARGOYLE_TYPE_BOOL },
|
|
{ GARGOYLE_MK_OPTN("bar"), 0, "no-", 3, GARGOYLE_TYPE_UINT }
|
|
};
|
|
|
|
uint16_t optc = sizeof(optv) / sizeof(struct gargoyle_optn);
|
|
|
|
struct gargoyle_optn *optn = gargoyle_find_brand(optc, optv, "", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "foo", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "foo", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "no-foo", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "foo", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "no-foo", "", 0, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "no_foo", "no-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "foo", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "no_foo", "no-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "no_foo", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "No-Foo", "no-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "No-Foo", "no-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "foo", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "No-Foo", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "NO_FOO", "no-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "foo", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "bar", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "bar", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "ba", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "baro", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "floor", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "harrow", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_brand(optc, optv, "$#^*!@&(*(@&", "no-", 3, 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
}
|
|
|
|
void sleuth_test_find_emblem(void) {
|
|
struct gargoyle_optn optv[] = {
|
|
{ GARGOYLE_MK_OPTN("glu"), 'G', "no-", 3, GARGOYLE_TYPE_UINT },
|
|
{ GARGOYLE_MK_OPTN("foo"), 'f', "no-", 3, GARGOYLE_TYPE_BOOL },
|
|
{ GARGOYLE_MK_OPTN("bar"), 'b', "no-", 3, GARGOYLE_TYPE_DBLE },
|
|
{ GARGOYLE_MK_OPTN("blu"), 'B', "no-", 3, GARGOYLE_TYPE_UINT }
|
|
};
|
|
|
|
uint16_t optc = sizeof(optv) / sizeof(struct gargoyle_optn);
|
|
|
|
struct gargoyle_optn *optn = gargoyle_find_emblem(optc, optv, 'f', 0);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "foo", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'f', GARGOYLE_FLG_ECASE);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "foo", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'F', 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'F', GARGOYLE_FLG_ECASE);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "foo", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'b', 0);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "bar", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'b', GARGOYLE_FLG_ECASE);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "bar", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'B', 0);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "blu", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'B', GARGOYLE_FLG_ECASE);
|
|
CU_ASSERT_PTR_NOT_NULL(optn);
|
|
CU_ASSERT_NSTRING_EQUAL(optn->brand, "bar", optn->brand_sz);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'g', 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'o', 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'P', 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
|
|
optn = gargoyle_find_emblem(optc, optv, 'q', 0);
|
|
CU_ASSERT_PTR_NULL(optn);
|
|
}
|