667 lines
22 KiB
C
667 lines
22 KiB
C
#include <CUnit/Basic.h>
|
|
#include <gargoyle/scribe.h>
|
|
#include <gargoyle/test/scribe.h>
|
|
#include <limits.h>
|
|
|
|
int init_suite_scribe(void) {
|
|
return CUE_SUCCESS;
|
|
}
|
|
|
|
int clean_suite_scribe(void) {
|
|
return CUE_SUCCESS;
|
|
}
|
|
|
|
void scribe_test_from_bool(void) {
|
|
uint8_t foo = 0;
|
|
|
|
struct gargoyle_optn opts[] = {
|
|
{ GARGOYLE_EZ_OPTN("foo", foo), GARGOYLE_TYPE_BOOL }
|
|
};
|
|
|
|
uint8_t res = gargoyle_from_bool(opts, "", "no-", 3, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "", "", 0, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "no-", 3, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "no-", 3, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "", 0, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "", 0, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "no-", 3, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "no-", 2, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "no-", 2, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "no-", 3, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-", "no-", 3, 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
// ...
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No-", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No_", 3, GARGOYLE_FLG_ICASE);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "NO-bar", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "no_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No-", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "no_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No_", 3, GARGOYLE_FLG_SYMBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "NO-bar", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "no_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "NO_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No-", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "foo", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-foo", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no_Foo", "no_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "bar", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no-bar", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_FALSE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "noon", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "no", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "No", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
|
|
res = gargoyle_from_bool(opts, "Bar", "No_", 3, GARGOYLE_FLG_FLXBL);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_TRUE(foo);
|
|
}
|
|
|
|
void scribe_test_from_rope(void) {
|
|
uint64_t uint_val = 0;
|
|
int64_t sint_val = 0;
|
|
double dble_val = 0;
|
|
char rope_val[10];
|
|
|
|
struct gargoyle_optn opts[] = {
|
|
{ GARGOYLE_EZ_OPTN("uint", uint_val), GARGOYLE_TYPE_UINT },
|
|
{ GARGOYLE_EZ_OPTN("sint", sint_val), GARGOYLE_TYPE_SINT },
|
|
{ GARGOYLE_EZ_OPTN("dble", dble_val), GARGOYLE_TYPE_DBLE },
|
|
{ GARGOYLE_CS_OPTN("rope", rope_val), GARGOYLE_TYPE_ROPE }
|
|
};
|
|
|
|
uint8_t res = gargoyle_from_rope(&opts[0], "42", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_EQUAL(uint_val, 42);
|
|
|
|
res = gargoyle_from_rope(&opts[0], "42u", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_UINT);
|
|
|
|
res = gargoyle_from_rope(&opts[0], ")(*&^%$#@!~", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_UINT);
|
|
|
|
res = gargoyle_from_rope(&opts[0], "thunderfury", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_UINT);
|
|
|
|
res = gargoyle_from_rope(&opts[0], "", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_EQUAL(uint_val, 0);
|
|
|
|
res = gargoyle_from_rope(&opts[0], "-1", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_EQUAL(uint_val, ULONG_MAX);
|
|
|
|
res = gargoyle_from_rope(&opts[0], "-19", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_EQUAL(uint_val, ULONG_MAX - 18);
|
|
|
|
res = gargoyle_from_rope(&opts[0], "42.42", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_UINT);
|
|
|
|
res = gargoyle_from_rope(&opts[0], "-8.19", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_UINT);
|
|
|
|
res = gargoyle_from_rope(&opts[1], "42", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_EQUAL(sint_val, 42);
|
|
|
|
res = gargoyle_from_rope(&opts[1], "42u", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_SINT);
|
|
|
|
res = gargoyle_from_rope(&opts[1], ")(*&^%$#@!~", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_SINT);
|
|
|
|
res = gargoyle_from_rope(&opts[1], "thunderfury", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_SINT);
|
|
|
|
res = gargoyle_from_rope(&opts[1], "", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_EQUAL(sint_val, 0);
|
|
|
|
res = gargoyle_from_rope(&opts[1], "-1", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_EQUAL(sint_val, -1);
|
|
|
|
res = gargoyle_from_rope(&opts[1], "-19", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_EQUAL(sint_val, -19);
|
|
|
|
res = gargoyle_from_rope(&opts[1], "42.42", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_SINT);
|
|
|
|
res = gargoyle_from_rope(&opts[1], "-8.19", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_SINT);
|
|
|
|
res = gargoyle_from_rope(&opts[2], "42", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_DOUBLE_EQUAL(dble_val, 42.0, 0.0);
|
|
|
|
res = gargoyle_from_rope(&opts[2], "42u", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_DBLE);
|
|
|
|
res = gargoyle_from_rope(&opts[2], ")(*&^%$#@!~", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_DBLE);
|
|
|
|
res = gargoyle_from_rope(&opts[2], "thunderfury", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_INVALID_DBLE);
|
|
|
|
res = gargoyle_from_rope(&opts[2], "", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_DOUBLE_EQUAL(dble_val, 0.0, 0.0);
|
|
|
|
res = gargoyle_from_rope(&opts[2], "-1", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_DOUBLE_EQUAL(dble_val, -1.0, 0.0);
|
|
|
|
res = gargoyle_from_rope(&opts[2], "-19", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_DOUBLE_EQUAL(dble_val, -19.0, 0.0);
|
|
|
|
res = gargoyle_from_rope(&opts[2], "42.42", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_DOUBLE_EQUAL(dble_val, 42.42, 0.0);
|
|
|
|
res = gargoyle_from_rope(&opts[2], "-8.19", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_DOUBLE_EQUAL(dble_val, -8.19, 0.0);
|
|
|
|
res = gargoyle_from_rope(&opts[3], "Hello, world!", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_NSTRING_EQUAL(rope_val, "Hello, wo", 9);
|
|
|
|
res = gargoyle_from_rope(&opts[3], "Hello!", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_NSTRING_EQUAL(rope_val, "Hello!", 9);
|
|
|
|
res = gargoyle_from_rope(&opts[3], "Thunderfury, Blessed Blade of the Windseeker", 0);
|
|
CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS);
|
|
CU_ASSERT_NSTRING_EQUAL(rope_val, "Thunderfu", 9);
|
|
}
|