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" static void class2string(char class[256], char* buf) { size_t i; for (i = 0; i < 256; ++i) { if (class[i]) *buf++ = (char)i; } *buf = '\0'; } 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 }, { "abcabc", "abc", VAR_OK }, { "a-z", "abcdefghijklmnopqrstuvwxyz", VAR_OK }, { "a-eA-Eabcdef-", "-ABCDEabcdef", VAR_OK }, { "-a-eA-Eabcdef-", "-ABCDEabcdef", VAR_OK }, { "0-9-", "-0123456789", VAR_OK }, { "g-a", NULL, VAR_INCORRECT_CLASS_SPEC } }; size_t i; char class[256]; char tmp[1024]; for (i = 0; i < sizeof(tests) / sizeof(struct test_case); ++i) { if (expand_character_class(tests[i].input, class) != tests[i].rc) { printf("expand_character_class() failed test case %d.\n", i); return 1; } if (tests[i].expected != NULL) { class2string(class, tmp); if (strcmp(tmp, tests[i].expected) != 0) { printf("expand_character_class() 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 @@