1 #include <stic.h>
2 
3 #include <stdlib.h> /* free() */
4 #include <string.h> /* memset() */
5 
6 #include "../../src/engine/parsing.h"
7 #include "../../src/engine/var.h"
8 
9 #include "asserts.h"
10 
TEST(empty_ok)11 TEST(empty_ok)
12 {
13 	ASSERT_OK("''", "");
14 }
15 
TEST(simple_ok)16 TEST(simple_ok)
17 {
18 	ASSERT_OK("'test'", "test");
19 }
20 
TEST(not_closed_error)21 TEST(not_closed_error)
22 {
23 	ASSERT_FAIL("'test", PE_MISSING_QUOTE);
24 }
25 
TEST(concatenation)26 TEST(concatenation)
27 {
28 	ASSERT_OK("'NV'.'AR'", "NVAR");
29 	ASSERT_OK("'NV' .'AR'", "NVAR");
30 	ASSERT_OK("'NV'. 'AR'", "NVAR");
31 	ASSERT_OK("'NV' . 'AR'", "NVAR");
32 }
33 
TEST(double_single_quote_ok)34 TEST(double_single_quote_ok)
35 {
36 	ASSERT_OK("''''", "'");
37 	ASSERT_OK("'foo''bar'", "foo'bar");
38 }
39 
TEST(triple_single_quote_error)40 TEST(triple_single_quote_error)
41 {
42 	ASSERT_FAIL("'''''", PE_MISSING_QUOTE);
43 }
44 
TEST(single_slash_ok)45 TEST(single_slash_ok)
46 {
47 	ASSERT_OK("'\\'", "\\");
48 }
49 
TEST(slash_t_ok)50 TEST(slash_t_ok)
51 {
52 	ASSERT_OK("'\\t'", "\\t");
53 }
54 
TEST(spaces_ok)55 TEST(spaces_ok)
56 {
57 	ASSERT_OK("' s y '", " s y ");
58 }
59 
TEST(dot_ok)60 TEST(dot_ok)
61 {
62 	ASSERT_OK("'a . c'", "a . c");
63 }
64 
TEST(very_long_string)65 TEST(very_long_string)
66 {
67 	var_t res_var = var_false();
68 
69 	char string[8192];
70 	string[0] = '\'';
71 	memset(string + 1, '0', sizeof(string) - 2U);
72 	string[sizeof(string) - 1U] = '\0';
73 
74 	assert_int_equal(PE_INTERNAL, parse(string, 0, &res_var));
75 	var_free(res_var);
76 }
77 
78 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
79 /* vim: set cinoptions+=t0 filetype=c : */
80