|
|
@ -26,24 +26,19 @@ START_TEST(read_char_fn_test) { |
|
|
|
START_TEST(read_fn_test) { |
|
|
|
START_TEST(read_fn_test) { |
|
|
|
FILE* s; |
|
|
|
FILE* s; |
|
|
|
|
|
|
|
|
|
|
|
printf("%s: %d\n", __FILE__, __LINE__); |
|
|
|
|
|
|
|
char hello[] = "hello"; |
|
|
|
char hello[] = "hello"; |
|
|
|
s = fmemopen(hello, sizeof(hello), "r"); |
|
|
|
s = fmemopen(hello, sizeof(hello), "r"); |
|
|
|
printf("%s: %d\n", __FILE__, __LINE__); |
|
|
|
|
|
|
|
ck_assert_str_eq(SYMBOL(read_fn(LIST(stream(s)), NIL)).data, hello); |
|
|
|
ck_assert_str_eq(SYMBOL(read_fn(LIST(stream(s)), NIL)).data, hello); |
|
|
|
printf("%s: %d\n", __FILE__, __LINE__); |
|
|
|
|
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
|
|
|
|
|
|
|
|
char funny[] = "69.420"; |
|
|
|
char funny[] = "69.420"; |
|
|
|
s = fmemopen(funny, sizeof(funny), "r"); |
|
|
|
s = fmemopen(funny, sizeof(funny), "r"); |
|
|
|
ck_assert_double_eq(NUMBER(read_fn(LIST(stream(s)), NIL)), 69.420); |
|
|
|
ck_assert_double_eq(NUMBER(read_fn(LIST(stream(s)), NIL)), 69.420); |
|
|
|
printf("%s: %d\n", __FILE__, __LINE__); |
|
|
|
|
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
|
|
|
|
|
|
|
|
char list[] = "(1 2 3)"; |
|
|
|
char list[] = "(1 2 3)"; |
|
|
|
s = fmemopen(list, sizeof(list), "r"); |
|
|
|
s = fmemopen(list, sizeof(list), "r"); |
|
|
|
Pointer result = read_fn(LIST(stream(s)), NIL); |
|
|
|
Pointer result = read_fn(LIST(stream(s)), NIL); |
|
|
|
printf("%s: %d: %d\n", __FILE__, __LINE__, TYPE(CAR(result))); |
|
|
|
|
|
|
|
ck_assert_double_eq(NUMBER(CAR(result)), 1); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(result)), 1); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(CDR(result))), 2); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(CDR(result))), 2); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(CDR(CDR(result)))), 3); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(CDR(CDR(result)))), 3); |
|
|
@ -65,17 +60,17 @@ START_TEST(read_char_macro_fn_test) { |
|
|
|
|
|
|
|
|
|
|
|
char a[] = "a"; |
|
|
|
char a[] = "a"; |
|
|
|
s = fmemopen(a, sizeof(a), "r"); |
|
|
|
s = fmemopen(a, sizeof(a), "r"); |
|
|
|
ck_assert_uint_eq(CHAR(read_char_macro_fn(LIST(stream(s)), NIL)), 'a'); |
|
|
|
ck_assert_uint_eq(CHAR(read_char_macro(LIST(stream(s)), NIL)), 'a'); |
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
|
|
|
|
|
|
|
|
char ab[] = "ab"; |
|
|
|
char ab[] = "ab"; |
|
|
|
s = fmemopen(ab, sizeof(ab), "r"); |
|
|
|
s = fmemopen(ab, sizeof(ab), "r"); |
|
|
|
ck_assert_uint_eq(read_char_macro_fn(LIST(stream(s)), NIL), UNDEFINED); |
|
|
|
ck_assert_uint_eq(read_char_macro(LIST(stream(s)), NIL), UNDEFINED); |
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
|
|
|
|
|
|
|
|
unsigned char smile[] = "😄"; |
|
|
|
unsigned char smile[] = "😄"; |
|
|
|
s = fmemopen(smile, sizeof(smile), "r"); |
|
|
|
s = fmemopen(smile, sizeof(smile), "r"); |
|
|
|
Pointer result = read_char_macro_fn(LIST(stream(s)), NIL); |
|
|
|
Pointer result = read_char_macro(LIST(stream(s)), NIL); |
|
|
|
ck_assert_int_eq(CHAR(result) & 0xFF, smile[0]); |
|
|
|
ck_assert_int_eq(CHAR(result) & 0xFF, smile[0]); |
|
|
|
ck_assert_int_eq((CHAR(result) >> 8) & 0xFF, smile[1]); |
|
|
|
ck_assert_int_eq((CHAR(result) >> 8) & 0xFF, smile[1]); |
|
|
|
ck_assert_int_eq((CHAR(result) >> 16) & 0xFF, smile[2]); |
|
|
|
ck_assert_int_eq((CHAR(result) >> 16) & 0xFF, smile[2]); |
|
|
@ -84,34 +79,34 @@ START_TEST(read_char_macro_fn_test) { |
|
|
|
|
|
|
|
|
|
|
|
char smile2[] = "😄😄"; |
|
|
|
char smile2[] = "😄😄"; |
|
|
|
s = fmemopen(smile2, sizeof(smile2), "r"); |
|
|
|
s = fmemopen(smile2, sizeof(smile2), "r"); |
|
|
|
ck_assert_uint_eq(read_char_macro_fn(LIST(stream(s)), NIL), UNDEFINED); |
|
|
|
ck_assert_uint_eq(read_char_macro(LIST(stream(s)), NIL), UNDEFINED); |
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
|
|
|
|
|
|
|
|
char space[] = "space"; |
|
|
|
char space[] = "space"; |
|
|
|
s = fmemopen(space, sizeof(space), "r"); |
|
|
|
s = fmemopen(space, sizeof(space), "r"); |
|
|
|
ck_assert_uint_eq(CHAR(read_char_macro_fn(LIST(stream(s)), NIL)), ' '); |
|
|
|
ck_assert_uint_eq(CHAR(read_char_macro(LIST(stream(s)), NIL)), ' '); |
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
|
|
|
|
|
|
|
|
char tab[] = "tab"; |
|
|
|
char tab[] = "tab"; |
|
|
|
s = fmemopen(tab, sizeof(tab), "r"); |
|
|
|
s = fmemopen(tab, sizeof(tab), "r"); |
|
|
|
ck_assert_uint_eq(CHAR(read_char_macro_fn(LIST(stream(s)), NIL)), '\t'); |
|
|
|
ck_assert_uint_eq(CHAR(read_char_macro(LIST(stream(s)), NIL)), '\t'); |
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
|
|
|
|
|
|
|
|
char newline[] = "newline"; |
|
|
|
char newline[] = "newline"; |
|
|
|
s = fmemopen(newline, sizeof(newline), "r"); |
|
|
|
s = fmemopen(newline, sizeof(newline), "r"); |
|
|
|
ck_assert_uint_eq(CHAR(read_char_macro_fn(LIST(stream(s)), NIL)), '\n'); |
|
|
|
ck_assert_uint_eq(CHAR(read_char_macro(LIST(stream(s)), NIL)), '\n'); |
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
|
|
|
|
|
|
|
|
char space2[] = "space2"; |
|
|
|
char space2[] = "space2"; |
|
|
|
s = fmemopen(space2, sizeof(space2), "r"); |
|
|
|
s = fmemopen(space2, sizeof(space2), "r"); |
|
|
|
ck_assert_uint_eq(read_char_macro_fn(LIST(stream(s)), NIL), UNDEFINED); |
|
|
|
ck_assert_uint_eq(read_char_macro(LIST(stream(s)), NIL), UNDEFINED); |
|
|
|
fclose(s); |
|
|
|
fclose(s); |
|
|
|
} END_TEST |
|
|
|
} END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(read_list_macro_fn_test) { |
|
|
|
START_TEST(read_list_macro_fn_test) { |
|
|
|
char list[] = "1 2 3)"; |
|
|
|
char list[] = "1 2 3)"; |
|
|
|
FILE* s = fmemopen(list, sizeof(list), "r"); |
|
|
|
FILE* s = fmemopen(list, sizeof(list), "r"); |
|
|
|
Pointer result = read_list_macro_fn(LIST(stream(s)), NIL); |
|
|
|
Pointer result = read_list_macro(LIST(stream(s)), NIL); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(result)), 1); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(result)), 1); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(CDR(result))), 2); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(CDR(result))), 2); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(CDR(CDR(result)))), 3); |
|
|
|
ck_assert_double_eq(NUMBER(CAR(CDR(CDR(result)))), 3); |
|
|
@ -119,7 +114,7 @@ START_TEST(read_list_macro_fn_test) { |
|
|
|
} END_TEST |
|
|
|
} END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(read_right_paren_macro_fn_test) { |
|
|
|
START_TEST(read_right_paren_macro_fn_test) { |
|
|
|
ck_assert_uint_eq(read_right_paren_macro_fn(NIL, NIL), NIL); |
|
|
|
ck_assert_uint_eq(read_right_paren_macro(NIL, NIL), NIL); |
|
|
|
} END_TEST |
|
|
|
} END_TEST |
|
|
|
|
|
|
|
|
|
|
|
static char buffer[] = "hello, world"; |
|
|
|
static char buffer[] = "hello, world"; |
|
|
|