Commit 6dd0ccdf authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

testsuite: add parsing test case for win32 line endings

Should handle \r\n as well as \n instead of relying on
the file reader to translate it.
parent 1430f02c
......@@ -13,7 +13,7 @@ TESTS = \
perf_opcodes_sys perf_parse \
memcpy_speed \
abi \
test-limits
test-limits test_parse
noinst_PROGRAMS = $(TESTS) generate_xml_table generate_xml_table2 \
generate_opcodes_sys compile_parse compile_parse_c memcpy_speed \
......@@ -22,7 +22,8 @@ noinst_PROGRAMS = $(TESTS) generate_xml_table generate_xml_table2 \
bytecode_parse \
compile_opcodes_sys_c \
compile_opcodes_sys \
show_parse
show_parse \
test_parse
EXTRA_DIST = test.orc
......
/* Test orc_parse() to make sure it handles both \r\n and \n line endings */
#include <orc/orc.h>
#include <orc-test/orctest.h>
#include <orc/orcparse.h>
#include <stdio.h>
#include <stdlib.h>
const char txt_unix[] = ".function orc_add_s16\n"
".dest 2 d1 orc_int16\n.source 2 s1 orc_int16\n.source 2 s2 orc_int16\n"
"\naddw d1, s1, s2\n";
const char txt_win32[] = ".function orc_add_s16\r\n"
".dest 2 d1 orc_int16\r\n.source 2 s1 orc_int16\r\n.source 2 s2 orc_int16\r\n"
"\r\naddw d1, s1, s2\r\n";
void output_code (OrcProgram * p, FILE * output);
void output_code_header (OrcProgram * p, FILE * output);
void output_code_test (OrcProgram * p, FILE * output);
int verbose = FALSE;
int error = FALSE;
int
main (int argc, char *argv[])
{
OrcProgram **programs;
OrcCompileResult cres;
int n, i;
orc_init ();
orc_test_init ();
/* 1 - unix */
n = orc_parse (txt_unix, &programs);
for (i = 0; i < n; i++) {
if (verbose)
printf ("%s\n", programs[i]->name);
orc_test_compare_output_full (programs[i], 0);
cres = orc_program_compile (programs[i]);
if (cres != ORC_COMPILE_RESULT_OK) {
fprintf (stderr, "compile error: %d\n", cres);
error = TRUE;
}
orc_program_free (programs[i]);
}
if (error || n == 0)
return 1;
/* 2 - windows */
n = orc_parse (txt_win32, &programs);
for (i = 0; i < n; i++) {
if (verbose)
printf ("%s\n", programs[i]->name);
orc_test_compare_output_full (programs[i], 0);
cres = orc_program_compile (programs[i]);
if (cres != ORC_COMPILE_RESULT_OK) {
fprintf (stderr, "compile error: %d\n", cres);
error = TRUE;
}
orc_program_free (programs[i]);
}
if (error || n == 0)
return 1;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment