Implement String structure and update Location/Token to use it
This commit is contained in:
+6
-6
@@ -98,21 +98,21 @@ static void test_tokenstream_info(void) {
|
||||
if (t1.token != TOKEN_MODULE) fail("expected TOKEN_MODULE");
|
||||
|
||||
char buf1[32];
|
||||
memcpy(buf1, t1.text, t1.text_length);
|
||||
buf1[t1.text_length] = '\0';
|
||||
memcpy(buf1, t1.text.data, t1.text.length);
|
||||
buf1[t1.text.length] = '\0';
|
||||
assert_str("module", buf1, "info: expected 'module'");
|
||||
if (t1.location.line != 1) fail("expected line 1");
|
||||
if (t1.location.column != 1) fail("expected column 1");
|
||||
if (t1.location.column_start != 1) fail("expected column 1");
|
||||
|
||||
Token t2 = tokenstream_next(ts);
|
||||
if (t2.token != TOKEN_IDENTIFIER) fail("expected TOKEN_IDENTIFIER");
|
||||
|
||||
char buf2[32];
|
||||
memcpy(buf2, t2.text, t2.text_length);
|
||||
buf2[t2.text_length] = '\0';
|
||||
memcpy(buf2, t2.text.data, t2.text.length);
|
||||
buf2[t2.text.length] = '\0';
|
||||
assert_str("main", buf2, "info: expected 'main'");
|
||||
if (t2.location.line != 1) fail("expected line 1");
|
||||
if (t2.location.column != 8) fail("expected column 8");
|
||||
if (t2.location.column_start != 8) fail("expected column 8");
|
||||
|
||||
tokenstream_close(ts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user