fix scanner_print_errors
This commit is contained in:
+11
-5
@@ -1,5 +1,6 @@
|
||||
#include <assert.h>
|
||||
#include <criterion/criterion.h>
|
||||
#include <stdio.h>
|
||||
#include "cig.h"
|
||||
|
||||
Test(scanner, looks_like_float) {
|
||||
@@ -58,12 +59,17 @@ Test(scanner, print_errors) {
|
||||
"+. false\n"
|
||||
"abc false\n"
|
||||
"+x false\n";
|
||||
FILE *f = tmpfile();
|
||||
with_borrow(allocator) {
|
||||
scanner_t scanner = make_scanner("test", buffer, allocator);
|
||||
while (!scan_eof(&scanner)) {
|
||||
// TODO
|
||||
cr_assert(false);
|
||||
}
|
||||
scanner_t scanner = make_scanner(__FILE__, buffer, allocator);
|
||||
scan_result_t res1 = scan_error(&scanner, "ignore this\n");
|
||||
scan_result_t res2 = scan_error(&scanner, "and this\n");
|
||||
scan_result_t res3 = scan_value(.i64=10);
|
||||
scan_result_t res4 = scan_value(.string_literal="foobar");
|
||||
|
||||
cr_assert(scanner_print_errors(f, res1, res2));
|
||||
cr_assert(scanner_print_errors(f, res1, res2, res3, res4));
|
||||
cr_assert(!scanner_print_errors(f, res3, res4));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user