summaryrefslogtreecommitdiff
path: root/source/tests
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-03-01 00:53:19 +0100
committerMitya Selivanov <automainint@guattari.tech>2024-03-01 00:53:19 +0100
commita6f51ee3faf37bfcb759b96ee76c85c490395b48 (patch)
treef0afc19a437319671678cf9b16a43682bba6b529 /source/tests
parentc6474ea8adbbc21878eebaecbca748fa4f65f8ee (diff)
downloadkit-a6f51ee3faf37bfcb759b96ee76c85c490395b48.zip
Remove unnecessary macro
Diffstat (limited to 'source/tests')
-rw-r--r--source/tests/input_buffer.test.c44
-rw-r--r--source/tests/input_stream.test.c4
-rw-r--r--source/tests/xml.test.c66
3 files changed, 61 insertions, 53 deletions
diff --git a/source/tests/input_buffer.test.c b/source/tests/input_buffer.test.c
index 1ec1ad4..aba9a9b 100644
--- a/source/tests/input_buffer.test.c
+++ b/source/tests/input_buffer.test.c
@@ -5,8 +5,8 @@
TEST("input buffer read once") {
str_t text = { .size = 3, .values = "foo" };
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t tok = ib_read(ib_token(&buf), 3);
@@ -21,8 +21,8 @@ TEST("input buffer read once") {
TEST("input buffer read again") {
str_t text = { .size = 6, .values = "foobar" };
str_t foo = { .size = 3, .values = "foo" };
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t first = ib_read(ib_token(&buf), 3);
ib_token_t second = ib_read(ib_token(&buf), 3);
@@ -38,8 +38,8 @@ TEST("input buffer read twice") {
str_t text = { .size = 6, .values = "foobar" };
str_t foo = { .size = 3, .values = "foo" };
str_t bar = { .size = 3, .values = "bar" };
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t first = ib_read(ib_token(&buf), 3);
ib_token_t second = ib_read(first, 3);
@@ -61,8 +61,8 @@ static b8 is_integer_(str_t const data, void *_) {
TEST("input buffer read integer once") {
str_t text = { .size = 9, .values = "31415 foo" };
str_t num = { .size = 5, .values = "31415" };
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t tok = ib_while(ib_token(&buf), is_integer_, NULL);
@@ -78,8 +78,8 @@ TEST("input buffer read integer twice") {
str_t text = { .size = 6, .values = "314 15" };
str_t num_0 = { .size = 3, .values = "314" };
str_t num_1 = { .size = 2, .values = "15" };
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t first = ib_while(ib_token(&buf), is_integer_, NULL);
ib_token_t second = ib_read(first, 1);
@@ -98,8 +98,8 @@ TEST("input buffer read integer twice") {
TEST("input buffer any") {
str_t text = SZ("01234bbdac");
str_t expect = SZ("01234");
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t tok = ib_any(ib_token(&buf), SZ("01234"));
@@ -113,8 +113,8 @@ TEST("input buffer any") {
TEST("input buffer none") {
str_t text = SZ("01234bbdac");
str_t expect = SZ("01234");
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t tok = ib_none(ib_token(&buf), SZ("abcd"));
@@ -128,8 +128,8 @@ TEST("input buffer none") {
TEST("input buffer until") {
str_t text = SZ("01234bbdac");
str_t expect = SZ("01234");
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t tok = ib_none(ib_token(&buf), SZ("bbdac"));
@@ -143,8 +143,8 @@ TEST("input buffer until") {
TEST("input buffer exact success") {
str_t text = SZ("01234bbdac");
str_t expect = SZ("01234");
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t tok = ib_exact(ib_token(&buf), SZ("01234"));
@@ -157,8 +157,8 @@ TEST("input buffer exact success") {
TEST("input buffer exact fail") {
str_t text = SZ("01234bbdac");
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t tok = ib_exact(ib_token(&buf), SZ("bbdac"));
@@ -170,8 +170,8 @@ TEST("input buffer exact fail") {
TEST("input buffer use after free") {
str_t text = SZ("foobarfoobar");
- is_handle_t in = IS_WRAP_STRING(text);
- input_buffer_t buf = ib_wrap(in, NULL);
+ is_handle_t in = is_wrap_string(text, NULL);
+ input_buffer_t buf = ib_init(in, NULL);
ib_token_t first = ib_exact(ib_token(&buf), SZ("foobar"));
ib_token_t second = ib_exact(first, ib_str(first));
diff --git a/source/tests/input_stream.test.c b/source/tests/input_stream.test.c
index 25ef721..23a9a99 100644
--- a/source/tests/input_stream.test.c
+++ b/source/tests/input_stream.test.c
@@ -11,7 +11,7 @@ TEST("input stream wrap string") {
str_t foo_ref = { .size = sizeof(foo) - 1, .values = foo };
str_t bar_ref = { .size = sizeof(bar) - 1, .values = bar };
- is_handle_t in = IS_WRAP_STRING(foo_ref);
+ is_handle_t in = is_wrap_string(foo_ref, NULL);
char buf[4];
str_t buf_ref = { .size = sizeof(buf), .values = buf };
@@ -33,7 +33,7 @@ TEST("input stream wrap file") {
f = fopen("_kit_temp", "rb");
- is_handle_t in = IS_WRAP_FILE(f);
+ is_handle_t in = is_wrap_file(f, NULL);
REQUIRE_EQ(IS_READ(in, SZ(bar)), SZ(bar).size);
REQUIRE(AR_EQUAL(SZ(foo), SZ(bar)));
diff --git a/source/tests/xml.test.c b/source/tests/xml.test.c
index 1534030..a31da8f 100644
--- a/source/tests/xml.test.c
+++ b/source/tests/xml.test.c
@@ -4,7 +4,7 @@
#include "../kit/test.h"
TEST("xml parse tag") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo> </foo>"));
+ is_handle_t is = is_wrap_string(SZ("<foo> </foo>"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -19,7 +19,7 @@ TEST("xml parse tag") {
}
TEST("xml parse tag with dash") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo-bar> </foo-bar>"));
+ is_handle_t is = is_wrap_string(SZ("<foo-bar> </foo-bar>"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -34,7 +34,7 @@ TEST("xml parse tag with dash") {
}
TEST("xml parse tag not closed") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo>"));
+ is_handle_t is = is_wrap_string(SZ("<foo>"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_PARSING_FAILED);
@@ -46,7 +46,7 @@ TEST("xml parse tag not closed") {
}
TEST("xml parse tag text") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo> bar </foo>"));
+ is_handle_t is = is_wrap_string(SZ("<foo> bar </foo>"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -62,7 +62,7 @@ TEST("xml parse tag text") {
}
TEST("xml parse empty tag") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo />"));
+ is_handle_t is = is_wrap_string(SZ("<foo />"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -77,7 +77,7 @@ TEST("xml parse empty tag") {
}
TEST("xml parse tail") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo></foo> bar"));
+ is_handle_t is = is_wrap_string(SZ("<foo></foo> bar"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -92,7 +92,7 @@ TEST("xml parse tail") {
}
TEST("xml parse empty tail") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo /> bar"));
+ is_handle_t is = is_wrap_string(SZ("<foo /> bar"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -107,7 +107,7 @@ TEST("xml parse empty tail") {
}
TEST("xml parse property") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo bar=\"42\"></foo>"));
+ is_handle_t is = is_wrap_string(SZ("<foo bar=\"42\"></foo>"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -126,7 +126,7 @@ TEST("xml parse property") {
}
TEST("xml parse empty property") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo bar=\"42\" />"));
+ is_handle_t is = is_wrap_string(SZ("<foo bar=\"42\" />"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -145,7 +145,7 @@ TEST("xml parse empty property") {
}
TEST("xml parse child") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo><bar></bar></foo>"));
+ is_handle_t is = is_wrap_string(SZ("<foo><bar></bar></foo>"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -162,7 +162,8 @@ TEST("xml parse child") {
}
TEST("xml parse child with text and tail") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo>text<bar /> tail</foo>"));
+ is_handle_t is = is_wrap_string(SZ("<foo>text<bar /> tail</foo>"),
+ NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -182,7 +183,7 @@ TEST("xml parse child with text and tail") {
}
TEST("xml parse declaration") {
- is_handle_t is = IS_WRAP_STRING(SZ("<?foo ?>"));
+ is_handle_t is = is_wrap_string(SZ("<?foo ?>"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -197,7 +198,7 @@ TEST("xml parse declaration") {
}
TEST("xml parse comment") {
- is_handle_t is = IS_WRAP_STRING(SZ("<!-- foo --><bar />"));
+ is_handle_t is = is_wrap_string(SZ("<!-- foo --><bar />"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -212,7 +213,8 @@ TEST("xml parse comment") {
}
TEST("xml parse comment before text") {
- is_handle_t is = IS_WRAP_STRING(SZ("<!-- foo --> bar <tag />"));
+ is_handle_t is = is_wrap_string(SZ("<!-- foo --> bar <tag />"),
+ NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -227,7 +229,8 @@ TEST("xml parse comment before text") {
}
TEST("xml parse comment after text") {
- is_handle_t is = IS_WRAP_STRING(SZ("foo <!-- bar --><tag />"));
+ is_handle_t is = is_wrap_string(SZ("foo <!-- bar --><tag />"),
+ NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -242,8 +245,8 @@ TEST("xml parse comment after text") {
}
TEST("xml parse comment between text") {
- is_handle_t is = IS_WRAP_STRING(
- SZ("foo<!-- comment --> bar<tag />"));
+ is_handle_t is = is_wrap_string(
+ SZ("foo<!-- comment --> bar<tag />"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -258,7 +261,7 @@ TEST("xml parse comment between text") {
}
TEST("xml parse comment tail") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo /><!-- tail -->"));
+ is_handle_t is = is_wrap_string(SZ("<foo /><!-- tail -->"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -273,7 +276,8 @@ TEST("xml parse comment tail") {
}
TEST("xml parse comment tail before text") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo /><!-- tail --> bar"));
+ is_handle_t is = is_wrap_string(SZ("<foo /><!-- tail --> bar"),
+ NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -289,7 +293,8 @@ TEST("xml parse comment tail before text") {
}
TEST("xml parse comment tail after text") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo /> bar <!-- tail -->"));
+ is_handle_t is = is_wrap_string(SZ("<foo /> bar <!-- tail -->"),
+ NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -305,7 +310,8 @@ TEST("xml parse comment tail after text") {
}
TEST("xml parse comment tail between text") {
- is_handle_t is = IS_WRAP_STRING(SZ("<tag />foo<!-- tail --> bar"));
+ is_handle_t is = is_wrap_string(SZ("<tag />foo<!-- tail --> bar"),
+ NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -321,7 +327,7 @@ TEST("xml parse comment tail between text") {
}
TEST("xml parse escaped text") {
- is_handle_t is = IS_WRAP_STRING(SZ("&lt;foo&gt;"));
+ is_handle_t is = is_wrap_string(SZ("&lt;foo&gt;"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -336,7 +342,8 @@ TEST("xml parse escaped text") {
}
TEST("xml parse escaped quote property") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo bar=\"&amp;&quot;\" />"));
+ is_handle_t is = is_wrap_string(SZ("<foo bar=\"&amp;&quot;\" />"),
+ NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -357,7 +364,8 @@ TEST("xml parse escaped quote property") {
}
TEST("xml parse escaped apostrophe property") {
- is_handle_t is = IS_WRAP_STRING(SZ("<foo bar='&amp;&apos;' />"));
+ is_handle_t is = is_wrap_string(SZ("<foo bar='&amp;&apos;' />"),
+ NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -377,7 +385,7 @@ TEST("xml parse escaped apostrophe property") {
}
TEST("xml parse invalid escape") {
- is_handle_t is = IS_WRAP_STRING(SZ("&foobar;"));
+ is_handle_t is = is_wrap_string(SZ("&foobar;"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_PARSING_FAILED);
@@ -389,8 +397,8 @@ TEST("xml parse invalid escape") {
}
TEST("xml full text") {
- is_handle_t is = IS_WRAP_STRING(
- SZ("<tag>foo <a>text</a> bar <b>text</b> tail</tag>"));
+ is_handle_t is = is_wrap_string(
+ SZ("<tag>foo <a>text</a> bar <b>text</b> tail</tag>"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);
@@ -407,8 +415,8 @@ TEST("xml full text") {
}
TEST("xml property") {
- is_handle_t is = IS_WRAP_STRING(
- SZ("<tag foo=\"123\" bar=\"456\" />"));
+ is_handle_t is = is_wrap_string(
+ SZ("<tag foo=\"123\" bar=\"456\" />"), NULL);
xml_parse_result_t res = xml_parse(is, NULL);
REQUIRE_EQ(res.status, KIT_OK);