Skip to content

Commit ba2c8c6

Browse files
committed
Call buffer_init before passing the buffers into erbx_lex_to_buffer
1 parent 4b97003 commit ba2c8c6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ int main(int argc, char* argv[]) {
1414
char* source = erbx_read_file(argv[1]);
1515
buffer_T output;
1616

17+
buffer_init(&output);
18+
1719
erbx_lex_to_buffer(source, &output);
1820

1921
printf("%s", output.value);

test/test_tags.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ TEST(test_empty_file)
55
char* html = "";
66
buffer_T output;
77

8+
buffer_init(&output);
9+
810
erbx_lex_to_buffer(html, &output);
911

1012
ck_assert_str_eq(output.value, "#<Token type=TOKEN_EOF value='' range=[0, 0] start=1:0 end=1:0>\n");
@@ -16,6 +18,8 @@ TEST(test_basic_tag)
1618
char* html = "<html></html>";
1719
buffer_T output;
1820

21+
buffer_init(&output);
22+
1923
erbx_lex_to_buffer(html, &output);
2024

2125
ck_assert_str_eq(
@@ -36,6 +40,8 @@ TEST(test_basic_void_tag)
3640
char* html = "<img />";
3741
buffer_T output;
3842

43+
buffer_init(&output);
44+
3945
erbx_lex_to_buffer(html, &output);
4046

4147
ck_assert_str_eq(
@@ -53,6 +59,8 @@ TEST(test_namespaced_tag)
5359
char* html = "<ns:table></ns:table>";
5460
buffer_T output;
5561

62+
buffer_init(&output);
63+
5664
erbx_lex_to_buffer(html, &output);
5765

5866
ck_assert_str_eq(
@@ -73,6 +81,8 @@ TEST(test_text_content)
7381
char* html = "<h1>Hello World</h1>";
7482
buffer_T output;
7583

84+
buffer_init(&output);
85+
7686
erbx_lex_to_buffer(html, &output);
7787

7888
ck_assert_str_eq(
@@ -94,6 +104,8 @@ TEST(test_attribute_value_double_quotes)
94104
char* html = "<img value=\"hello world\" />";
95105
buffer_T output;
96106

107+
buffer_init(&output);
108+
97109
erbx_lex_to_buffer(html, &output);
98110

99111
ck_assert_str_eq(
@@ -116,6 +128,8 @@ TEST(test_attribute_value_single_quotes)
116128
char* html = "<img value='hello world' />";
117129
buffer_T output;
118130

131+
buffer_init(&output);
132+
119133
erbx_lex_to_buffer(html, &output);
120134

121135
ck_assert_str_eq(
@@ -138,6 +152,8 @@ END
138152
// char* html = "<img value=hello />";
139153
// buffer_T output;
140154
//
155+
// buffer_init(&output);
156+
//
141157
// erbx_lex_to_buffer(html, &output);
142158
//
143159
// ck_assert_str_eq(
@@ -158,6 +174,8 @@ TEST(test_attribute_value_empty_double_quotes)
158174
char* html = "<img value=\"\" />";
159175
buffer_T output;
160176

177+
buffer_init(&output);
178+
161179
erbx_lex_to_buffer(html, &output);
162180

163181
ck_assert_str_eq(
@@ -180,6 +198,8 @@ TEST(test_attribute_value_empty_single_quotes)
180198
char* html = "<img value='' />";
181199
buffer_T output;
182200

201+
buffer_init(&output);
202+
183203
erbx_lex_to_buffer(html, &output);
184204

185205
ck_assert_str_eq(
@@ -202,6 +222,8 @@ TEST(test_boolean_attribute)
202222
char* html = "<img required />";
203223
buffer_T output;
204224

225+
buffer_init(&output);
226+
205227
erbx_lex_to_buffer(html, &output);
206228

207229
ck_assert_str_eq(

0 commit comments

Comments
 (0)