Skip to content

Commit

Permalink
add tests for string parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
NiumXp authored and matthieu42Network committed Aug 16, 2023
1 parent 4c0b1ae commit 16f1f9e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/rules/samples/lexer_check_string.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void main(void)
{
char *str = "Pizza\
:yum:
";
}
2 changes: 2 additions & 0 deletions tests/rules/samples/lexer_check_string.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/rules/samples/lexer_check_string.c: Error!
String literal unterminated detected at line 3
15 changes: 15 additions & 0 deletions tests/rules/samples/lexer_check_string_2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
void main(void)
{
char *str = "Pizza\
:yum:";
x = L"eae";
x = L"\
será q\
x = ta certo?\"";
x = "";
x = "\
";
x = "PAH! poW\
XERAP\\\\\\\
";
}
42 changes: 42 additions & 0 deletions tests/rules/samples/lexer_check_string_2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
lexer_check_string_2.c - IsFuncDeclaration In "GlobalScope" from "None" line 1":
<VOID> <SPACE> <IDENTIFIER=main> <LPARENTHESIS> <VOID> <RPARENTHESIS> <NEWLINE>
lexer_check_string_2.c - IsBlockStart In "Function" from "GlobalScope" line 2":
<LBRACE> <NEWLINE>
lexer_check_string_2.c - IsVarDeclaration In "Function" from "GlobalScope" line 3":
<SPACE> <SPACE> <SPACE> <SPACE> <CHAR> <SPACE> <MULT> <IDENTIFIER=str> <SPACE> <ASSIGN> <SPACE> <STRING="Pizza\
:yum:"> <SEMI_COLON> <NEWLINE>
lexer_check_string_2.c - IsAssignation In "Function" from "GlobalScope" line 5":
<SPACE> <SPACE> <SPACE> <SPACE> <IDENTIFIER=x> <SPACE> <ASSIGN> <SPACE> <STRING=L"eae"> <SEMI_COLON> <NEWLINE>
lexer_check_string_2.c - IsAssignation In "Function" from "GlobalScope" line 6":
<SPACE> <SPACE> <SPACE> <SPACE> <IDENTIFIER=x> <SPACE> <ASSIGN> <SPACE> <STRING=L"\
será q\
x = ta certo?\""> <SEMI_COLON> <NEWLINE>
lexer_check_string_2.c - IsAssignation In "Function" from "GlobalScope" line 9":
<SPACE> <SPACE> <SPACE> <SPACE> <IDENTIFIER=x> <SPACE> <ASSIGN> <SPACE> <STRING=""> <SEMI_COLON> <NEWLINE>
lexer_check_string_2.c - IsAssignation In "Function" from "GlobalScope" line 10":
<SPACE> <SPACE> <SPACE> <SPACE> <IDENTIFIER=x> <SPACE> <ASSIGN> <SPACE> <STRING="\
"> <SEMI_COLON> <NEWLINE>
lexer_check_string_2.c - IsAssignation In "Function" from "GlobalScope" line 12":
<SPACE> <SPACE> <SPACE> <SPACE> <IDENTIFIER=x> <SPACE> <ASSIGN> <SPACE> <STRING="PAH! poW\
XERAP\\\\\\\
"> <SEMI_COLON> <NEWLINE>
lexer_check_string_2.c - IsBlockEnd In "Function" from "GlobalScope" line 15":
<RBRACE> <NEWLINE>
lexer_check_string_2.c: Error!
Error: INVALID_HEADER (line: 1, col: 1): Missing or invalid 42 header
Error: SPACE_BEFORE_FUNC (line: 1, col: 5): space before function name
Error: TOO_FEW_TAB (line: 3, col: 1): Missing tabs for indent level
Error: SPACE_REPLACE_TAB (line: 3, col: 5): Found space when expecting tab
Error: SPACE_REPLACE_TAB (line: 3, col: 9): Found space when expecting tab
Error: DECL_ASSIGN_LINE (line: 3, col: 15): Declaration and assignation on a single line
Error: NL_AFTER_VAR_DECL (line: 5, col: 1): Variable declarations must be followed by a newline
Error: TOO_FEW_TAB (line: 5, col: 1): Missing tabs for indent level
Error: SPACE_REPLACE_TAB (line: 5, col: 5): Found space when expecting tab
Error: TOO_FEW_TAB (line: 6, col: 1): Missing tabs for indent level
Error: SPACE_REPLACE_TAB (line: 6, col: 5): Found space when expecting tab
Error: TOO_FEW_TAB (line: 9, col: 1): Missing tabs for indent level
Error: SPACE_REPLACE_TAB (line: 9, col: 5): Found space when expecting tab
Error: TOO_FEW_TAB (line: 10, col: 1): Missing tabs for indent level
Error: SPACE_REPLACE_TAB (line: 10, col: 5): Found space when expecting tab
Error: TOO_FEW_TAB (line: 12, col: 1): Missing tabs for indent level
Error: SPACE_REPLACE_TAB (line: 12, col: 5): Found space when expecting tab
6 changes: 6 additions & 0 deletions tests/rules/samples/lexer_check_string_3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void main(void)
{
char *str = "Será que
se botar errado
assim, a norminette pega?";
}
2 changes: 2 additions & 0 deletions tests/rules/samples/lexer_check_string_3.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/rules/samples/lexer_check_string_3.c: Error!
String literal unterminated detected at line 3

0 comments on commit 16f1f9e

Please sign in to comment.