2023-07-10 15:51:21 +00:00
|
|
|
#include <cgreen/cgreen.h>
|
2023-07-12 19:22:54 +00:00
|
|
|
#include <bglibs/str.h>
|
2023-07-10 15:51:21 +00:00
|
|
|
#include "shortcodes.h"
|
|
|
|
|
|
|
|
Describe(parse);
|
|
|
|
BeforeEach(parse) {}
|
|
|
|
AfterEach(parse) {}
|
|
|
|
|
2023-07-12 19:22:54 +00:00
|
|
|
shortcode *result;
|
|
|
|
str s;
|
|
|
|
|
|
|
|
chunk_s(char *buffer, chunk c){
|
|
|
|
str_copyb(&s, buffer + c.start, c.len);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ensure(parse, empty_string)
|
|
|
|
{
|
2023-07-12 19:09:17 +00:00
|
|
|
char *input = "";
|
2023-07-12 19:22:54 +00:00
|
|
|
result = parse(input);
|
|
|
|
// This means no shortcodes in it
|
|
|
|
assert_that(result[0].name.len, is_equal_to(0));
|
2023-07-10 15:51:21 +00:00
|
|
|
}
|
|
|
|
|
2023-07-12 19:22:54 +00:00
|
|
|
Ensure(parse, simple_shortcode)
|
|
|
|
{
|
|
|
|
char *input = "{{% shortcode %}}";
|
|
|
|
result = parse(input);
|
|
|
|
chunk_s(input, result[0].name);
|
|
|
|
assert_that(s.s, is_equal_to_string("shortcode"));
|
|
|
|
assert_that(result[0].argcount, is_equal_to(0));
|
|
|
|
}
|
2023-07-10 15:51:21 +00:00
|
|
|
|
2023-07-12 19:22:54 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
str_init(&s);
|
2023-07-10 15:51:21 +00:00
|
|
|
TestSuite *suite = create_test_suite();
|
2023-07-12 19:09:17 +00:00
|
|
|
add_test_with_context(suite, parse, empty_string);
|
2023-07-12 19:22:54 +00:00
|
|
|
add_test_with_context(suite, parse, simple_shortcode);
|
2023-07-10 15:51:21 +00:00
|
|
|
return run_test_suite(suite, create_text_reporter());
|
|
|
|
}
|