head 1.2; access; symbols last-version-before-change-to-ossp-style:1.1.1.1 VAR_0_0_0:1.1.1.1 VENDOR:1.1.1; locks; strict; comment @ * @; 1.2 date 2001.11.13.12.08.32; author simons; state dead; branches; next 1.1; 1.1 date 2001.11.09.17.01.37; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2001.11.09.17.01.37; author rse; state Exp; branches; next ; desc @@ 1.2 log @- Moved all routines into a single source file var.c. - Renamed varexp.h to var.h. - Removed odin-based build system. - Moved test cases into var_test.c. - Adapted build system. @ text @#include "../internal.h" struct test_case { const char* input; const char* expected; var_rc_t rc; }; int main(int argc, char** argv) { struct test_case tests[] = { { "", "", VAR_OK }, { "\\", NULL, VAR_INCOMPLETE_NAMED_CHARACTER }, { "hello world", "hello world", VAR_OK }, { "\\n", "\n", VAR_OK }, {"\\t", "\t", VAR_OK }, { "\\rhello\\tworld\\n", "\rhello\tworld\n", VAR_OK }, { "\\x5a\\x5A", "ZZ", VAR_OK }, { "\\x5g\\x5A", NULL, VAR_INVALID_HEX }, { "\\x5", NULL, VAR_INCOMPLETE_HEX }, { "\\033", "\033", VAR_OK }, { "\\03", NULL, VAR_INCOMPLETE_OCTAL }, { "\\038", NULL, VAR_INVALID_OCTAL }, { "\\400", NULL, VAR_OCTAL_TOO_LARGE }, { "\\x{4243}", "BC", VAR_OK }, { "\\x{}", "", VAR_OK }, { "\\x{5a5A5a5A}", "ZZZZ", VAR_OK }, { "\\x{", NULL, VAR_INCOMPLETE_GROUPED_HEX }, { "x\\x{5a5A5a5A}a", "xZZZZa", VAR_OK }, { "x\\x{5a5A5a\\0015A}a", NULL, VAR_INVALID_HEX }, { "x\\x{5a\\x{5a}5A}a", NULL, VAR_INVALID_HEX } }; size_t i; char tmp[1024]; for (i = 0; i < sizeof(tests) / sizeof(struct test_case); ++i) { if (expand_named_characters(tests[i].input, strlen(tests[i].input), tmp) != tests[i].rc || (tests[i].expected != NULL && strcmp(tmp, tests[i].expected) != 0)) { printf("expand_named_characters() failed test case %d.\n", i); return 1; } } return 0; } @ 1.1 log @Initial revision @ text @@ 1.1.1.1 log @import first cut of OSSP var @ text @@