aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-03-13 01:48:49 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-03-13 01:48:49 +0100
commita2b3551dfb9460470bd79f5648bf597c517c40d4 (patch)
treeb82f50efbd76f581a281d61009811c1afabb0733
parent3ead966f48bc47444d7ec72f46e94e73557695a5 (diff)
downloadblogc-a2b3551dfb9460470bd79f5648bf597c517c40d4.tar.gz
blogc-a2b3551dfb9460470bd79f5648bf597c517c40d4.tar.bz2
blogc-a2b3551dfb9460470bd79f5648bf597c517c40d4.zip
*: use squareball error infrastructure
m---------squareball0
-rw-r--r--src/datetime-parser.c58
-rw-r--r--src/datetime-parser.h2
-rw-r--r--src/error.c47
-rw-r--r--src/error.h15
-rw-r--r--src/file.c4
-rw-r--r--src/file.h2
-rw-r--r--src/loader.c12
-rw-r--r--src/loader.h6
-rw-r--r--src/main.c4
-rw-r--r--src/renderer.c4
-rw-r--r--src/source-parser.c4
-rw-r--r--src/source-parser.h2
-rw-r--r--src/template-parser.c8
-rw-r--r--src/template-parser.h2
-rw-r--r--tests/check_datetime_parser.c216
-rw-r--r--tests/check_error.c44
-rw-r--r--tests/check_loader.c30
-rw-r--r--tests/check_renderer.c40
-rw-r--r--tests/check_source_parser.c122
-rw-r--r--tests/check_template_parser.c190
21 files changed, 386 insertions, 426 deletions
diff --git a/squareball b/squareball
-Subproject dd0430e75fe99aa41d638827a057f90a8090572
+Subproject ebc02478a78c83e5e62afc485a294e1c78442db
diff --git a/src/datetime-parser.c b/src/datetime-parser.c
index 0aeb702..0fa7aaf 100644
--- a/src/datetime-parser.c
+++ b/src/datetime-parser.c
@@ -47,14 +47,14 @@ typedef enum {
char*
blogc_convert_datetime(const char *orig, const char *format,
- blogc_error_t **err)
+ sb_error_t **err)
{
if (err == NULL || *err != NULL)
return NULL;
#ifndef HAVE_TIME_H
- *err = blogc_error_new(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new(BLOGC_WARNING_DATETIME_PARSER,
"Your operating system does not supports the datetime functionalities "
"used by blogc. Sorry.");
return NULL;
@@ -80,7 +80,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -91,7 +91,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_THIRD_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -102,7 +102,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FOURTH_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid third digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -111,7 +111,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff - 1900;
if (tmp < 0) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid year. Found %d, must be >= 1900.",
tmp + 1900);
break;
@@ -120,7 +120,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_HYPHEN;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid fourth digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -131,7 +131,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_MONTH;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between year and month. "
"Found '%c', must be '-'.", c);
break;
@@ -142,7 +142,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_MONTH;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of month. "
"Found '%c', must be integer >= 0 and <= 1.", c);
break;
@@ -151,7 +151,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff - 1;
if (tmp < 0 || tmp > 11) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid month. Found %d, must be >= 1 and <= 12.",
tmp + 1);
break;
@@ -160,7 +160,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_HYPHEN;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of month. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -171,7 +171,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_DAY;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between month and day. "
"Found '%c', must be '-'.", c);
break;
@@ -182,7 +182,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_DAY;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of day. "
"Found '%c', must be integer >= 0 and <= 3.", c);
break;
@@ -191,7 +191,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 1 || tmp > 31) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid day. Found %d, must be >= 1 and <= 31.",
tmp);
break;
@@ -200,7 +200,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SPACE;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of day. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -211,7 +211,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_HOUR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between date and time. "
"Found '%c', must be ' ' (empty space).", c);
break;
@@ -222,7 +222,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_HOUR;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of hours. "
"Found '%c', must be integer >= 0 and <= 2.", c);
break;
@@ -231,7 +231,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 0 || tmp > 23) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid hours. Found %d, must be >= 0 and <= 23.",
tmp);
break;
@@ -240,7 +240,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_COLON;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of hours. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -251,7 +251,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_MINUTE;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between hours and minutes. "
"Found '%c', must be ':'.", c);
break;
@@ -262,7 +262,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_MINUTE;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of minutes. "
"Found '%c', must be integer >= 0 and <= 5.", c);
break;
@@ -274,7 +274,7 @@ blogc_convert_datetime(const char *orig, const char *format,
// this won't happen because we are restricting the digits
// to 00-59 already, but lets keep the code here for
// reference.
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid minutes. Found %d, must be >= 0 and <= 59.",
tmp);
break;
@@ -283,7 +283,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_COLON;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of minutes. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -294,7 +294,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_SECOND;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between minutes and seconds. "
"Found '%c', must be ':'.", c);
break;
@@ -305,7 +305,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_SECOND;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of seconds. "
"Found '%c', must be integer >= 0 and <= 6.", c);
break;
@@ -314,7 +314,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 0 || tmp > 60) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid seconds. Found %d, must be >= 0 and <= 60.",
tmp);
break;
@@ -323,7 +323,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_DONE;
break;
}
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of seconds. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -355,7 +355,7 @@ blogc_convert_datetime(const char *orig, const char *format,
case DATETIME_SECOND_MINUTE:
case DATETIME_FIRST_SECOND:
case DATETIME_SECOND_SECOND:
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid datetime string. "
"Found '%s', formats allowed are: 'yyyy-mm-dd hh:mm:ss', "
"'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and 'yyyy-mm-dd'.",
@@ -374,7 +374,7 @@ blogc_convert_datetime(const char *orig, const char *format,
char buf[1024];
if (0 == strftime(buf, sizeof(buf), format, &t)) {
- *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
+ *err = sb_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Failed to format DATE variable, FORMAT is too long: %s",
format);
return NULL;
diff --git a/src/datetime-parser.h b/src/datetime-parser.h
index a5087b3..b2e65a1 100644
--- a/src/datetime-parser.h
+++ b/src/datetime-parser.h
@@ -12,6 +12,6 @@
#include "error.h"
char* blogc_convert_datetime(const char *orig, const char *format,
- blogc_error_t **err);
+ sb_error_t **err);
#endif /* _DATETIME_H */
diff --git a/src/error.c b/src/error.c
index f05049c..619ae01 100644
--- a/src/error.c
+++ b/src/error.c
@@ -18,31 +18,8 @@
#include "error.h"
-blogc_error_t*
-blogc_error_new(blogc_error_type_t type, const char *msg)
-{
- blogc_error_t *err = sb_malloc(sizeof(blogc_error_t));
- err->type = type;
- err->msg = sb_strdup(msg);
- return err;
-}
-
-
-blogc_error_t*
-blogc_error_new_printf(blogc_error_type_t type, const char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
- char *tmp = sb_strdup_vprintf(format, ap);
- va_end(ap);
- blogc_error_t *rv = blogc_error_new(type, tmp);
- free(tmp);
- return rv;
-}
-
-
-blogc_error_t*
-blogc_error_parser(blogc_error_type_t type, const char *src, size_t src_len,
+sb_error_t*
+blogc_error_parser(blogc_error_code_t type, const char *src, size_t src_len,
size_t current, const char *format, ...)
{
va_list ap;
@@ -90,12 +67,12 @@ blogc_error_parser(blogc_error_type_t type, const char *src, size_t src_len,
char *line = sb_strndup(src + linestart, lineend - linestart);
- blogc_error_t *rv = NULL;
+ sb_error_t *rv = NULL;
if (line[0] == '\0') // "near" message isn't useful if line is empty
- rv = blogc_error_new(type, msg);
+ rv = sb_error_new(type, msg);
else
- rv = blogc_error_new_printf(type,
+ rv = sb_error_new_printf(type,
"%s\nError occurred near line %d, position %d: %s", msg, lineno,
pos, line);
@@ -107,12 +84,12 @@ blogc_error_parser(blogc_error_type_t type, const char *src, size_t src_len,
void
-blogc_error_print(blogc_error_t *err)
+blogc_error_print(sb_error_t *err)
{
if (err == NULL)
return;
- switch(err->type) {
+ switch(err->code) {
case BLOGC_ERROR_SOURCE_PARSER:
fprintf(stderr, "blogc: error: source: %s\n", err->msg);
break;
@@ -129,13 +106,3 @@ blogc_error_print(blogc_error_t *err)
fprintf(stderr, "blogc: error: %s\n", err->msg);
}
}
-
-
-void
-blogc_error_free(blogc_error_t *err)
-{
- if (err == NULL)
- return;
- free(err->msg);
- free(err);
-}
diff --git a/src/error.h b/src/error.h
index caa86b0..e02afed 100644
--- a/src/error.h
+++ b/src/error.h
@@ -11,24 +11,17 @@
#include <stdlib.h>
#include <stdarg.h>
+#include <squareball.h>
typedef enum {
BLOGC_ERROR_SOURCE_PARSER = 1,
BLOGC_ERROR_TEMPLATE_PARSER,
BLOGC_ERROR_LOADER,
BLOGC_WARNING_DATETIME_PARSER,
-} blogc_error_type_t;
+} blogc_error_code_t;
-typedef struct {
- char *msg;
- blogc_error_type_t type;
-} blogc_error_t;
-
-blogc_error_t* blogc_error_new(blogc_error_type_t type, const char *msg);
-blogc_error_t* blogc_error_new_printf(blogc_error_type_t type, const char *format, ...);
-blogc_error_t* blogc_error_parser(blogc_error_type_t type, const char *src,
+sb_error_t* blogc_error_parser(blogc_error_code_t type, const char *src,
size_t src_len, size_t current, const char *format, ...);
-void blogc_error_print(blogc_error_t *err);
-void blogc_error_free(blogc_error_t *err);
+void blogc_error_print(sb_error_t *err);
#endif /* _ERROR_H */
diff --git a/src/file.c b/src/file.c
index dec7c1b..972f433 100644
--- a/src/file.c
+++ b/src/file.c
@@ -23,7 +23,7 @@
char*
-blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err)
+blogc_file_get_contents(const char *path, size_t *len, sb_error_t **err)
{
if (path == NULL || err == NULL || *err != NULL)
return NULL;
@@ -33,7 +33,7 @@ blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err)
if (fp == NULL) {
int tmp_errno = errno;
- *err = blogc_error_new_printf(BLOGC_ERROR_LOADER,
+ *err = sb_error_new_printf(BLOGC_ERROR_LOADER,
"Failed to open file (%s): %s", path, strerror(tmp_errno));
return NULL;
}
diff --git a/src/file.h b/src/file.h
index 97e5274..9c0674d 100644
--- a/src/file.h
+++ b/src/file.h
@@ -15,7 +15,7 @@
#define BLOGC_FILE_CHUNK_SIZE 1024
-char* blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err);
+char* blogc_file_get_contents(const char *path, size_t *len, sb_error_t **err);
int blogc_fprintf(FILE *stream, const char *format, ...);
#endif /* _FILE_H */
diff --git a/src/loader.c b/src/loader.c
index 8008c3a..fd184e5 100644
--- a/src/loader.c
+++ b/src/loader.c
@@ -60,7 +60,7 @@ blogc_get_filename(const char *f)
sb_slist_t*
-blogc_template_parse_from_file(const char *f, blogc_error_t **err)
+blogc_template_parse_from_file(const char *f, sb_error_t **err)
{
if (err == NULL || *err != NULL)
return NULL;
@@ -75,7 +75,7 @@ blogc_template_parse_from_file(const char *f, blogc_error_t **err)
sb_trie_t*
-blogc_source_parse_from_file(const char *f, blogc_error_t **err)
+blogc_source_parse_from_file(const char *f, sb_error_t **err)
{
if (err == NULL || *err != NULL)
return NULL;
@@ -98,9 +98,9 @@ blogc_source_parse_from_file(const char *f, blogc_error_t **err)
sb_slist_t*
-blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l, blogc_error_t **err)
+blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l, sb_error_t **err)
{
- blogc_error_t *tmp_err = NULL;
+ sb_error_t *tmp_err = NULL;
sb_slist_t *rv = NULL;
unsigned int with_date = 0;
@@ -125,10 +125,10 @@ blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l, blogc_error_t **er
char *f = tmp->data;
sb_trie_t *s = blogc_source_parse_from_file(f, &tmp_err);
if (s == NULL) {
- *err = blogc_error_new_printf(BLOGC_ERROR_LOADER,
+ *err = sb_error_new_printf(BLOGC_ERROR_LOADER,
"An error occurred while parsing source file: %s\n\n%s",
f, tmp_err->msg);
- blogc_error_free(tmp_err);
+ sb_error_free(tmp_err);
tmp_err = NULL;
sb_slist_free_full(rv, (sb_free_func_t) sb_trie_free);
rv = NULL;
diff --git a/src/loader.h b/src/loader.h
index 080aff6..8b0460e 100644
--- a/src/loader.h
+++ b/src/loader.h
@@ -13,9 +13,9 @@
#include "error.h"
char* blogc_get_filename(const char *f);
-sb_slist_t* blogc_template_parse_from_file(const char *f, blogc_error_t **err);
-sb_trie_t* blogc_source_parse_from_file(const char *f, blogc_error_t **err);
+sb_slist_t* blogc_template_parse_from_file(const char *f, sb_error_t **err);
+sb_trie_t* blogc_source_parse_from_file(const char *f, sb_error_t **err);
sb_slist_t* blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l,
- blogc_error_t **err);
+ sb_error_t **err);
#endif /* _LOADER_H */
diff --git a/src/main.c b/src/main.c
index 143c836..709b37e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -210,7 +210,7 @@ main(int argc, char **argv)
goto cleanup;
}
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = blogc_source_parse_from_files(config, sources, &err);
if (err != NULL) {
@@ -274,7 +274,7 @@ cleanup3:
blogc_template_free_stmts(l);
cleanup2:
sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
- blogc_error_free(err);
+ sb_error_free(err);
cleanup:
sb_trie_free(config);
free(template);
diff --git a/src/renderer.c b/src/renderer.c
index a7a7dd7..eb58e0d 100644
--- a/src/renderer.c
+++ b/src/renderer.c
@@ -46,11 +46,11 @@ blogc_format_date(const char *date, sb_trie_t *global, sb_trie_t *local)
if (date_format == NULL)
return sb_strdup(date);
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *rv = blogc_convert_datetime(date, date_format, &err);
if (err != NULL) {
blogc_error_print(err);
- blogc_error_free(err);
+ sb_error_free(err);
return sb_strdup(date);
}
return rv;
diff --git a/src/source-parser.c b/src/source-parser.c
index e3662a2..1047f06 100644
--- a/src/source-parser.c
+++ b/src/source-parser.c
@@ -31,7 +31,7 @@ typedef enum {
sb_trie_t*
-blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)
+blogc_source_parse(const char *src, size_t src_len, sb_error_t **err)
{
if (err == NULL || *err != NULL)
return NULL;
@@ -97,7 +97,7 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)
((current - start == 13) &&
(0 == strncmp("BLOGC_VERSION", src + start, 13))))
{
- *err = blogc_error_new_printf(BLOGC_ERROR_SOURCE_PARSER,
+ *err = sb_error_new_printf(BLOGC_ERROR_SOURCE_PARSER,
"'%s' variable is forbidden in source files. It will "
"be set for you by the compiler.", key);
break;
diff --git a/src/source-parser.h b/src/source-parser.h
index 460aedb..fb5306c 100644
--- a/src/source-parser.h
+++ b/src/source-parser.h
@@ -14,6 +14,6 @@
#include "error.h"
sb_trie_t* blogc_source_parse(const char *src, size_t src_len,
- blogc_error_t **err);
+ sb_error_t **err);
#endif /* _SOURCE_PARSER_H */
diff --git a/src/template-parser.c b/src/template-parser.c
index 6f23ef1..d61f90a 100644
--- a/src/template-parser.c
+++ b/src/template-parser.c
@@ -53,7 +53,7 @@ typedef enum {
sb_slist_t*
-blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)
+blogc_template_parse(const char *src, size_t src_len, sb_error_t **err)
{
if (err == NULL || *err != NULL)
return NULL;
@@ -597,14 +597,14 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)
*err = blogc_error_parser(BLOGC_ERROR_TEMPLATE_PARSER, src, src_len,
start2 - 1, "Found an open double-quoted string.");
else if (if_count != 0)
- *err = blogc_error_new_printf(BLOGC_ERROR_TEMPLATE_PARSER,
+ *err = sb_error_new_printf(BLOGC_ERROR_TEMPLATE_PARSER,
"%d open 'ifdef' and/or 'ifndef' statements were not closed!",
if_count);
else if (block_state != BLOCK_CLOSED)
- *err = blogc_error_new(BLOGC_ERROR_TEMPLATE_PARSER,
+ *err = sb_error_new(BLOGC_ERROR_TEMPLATE_PARSER,
"An open block was not closed!");
else if (foreach_open)
- *err = blogc_error_new(BLOGC_ERROR_TEMPLATE_PARSER,
+ *err = sb_error_new(BLOGC_ERROR_TEMPLATE_PARSER,
"An open 'foreach' statement was not closed!");
}
diff --git a/src/template-parser.h b/src/template-parser.h
index de5113e..88b46e9 100644
--- a/src/template-parser.h
+++ b/src/template-parser.h
@@ -45,7 +45,7 @@ typedef struct {
} blogc_template_stmt_t;
sb_slist_t* blogc_template_parse(const char *src, size_t src_len,
- blogc_error_t **err);
+ sb_error_t **err);
void blogc_template_free_stmts(sb_slist_t *stmts);
#endif /* _TEMPLATE_GRAMMAR_H */
diff --git a/tests/check_datetime_parser.c b/tests/check_datetime_parser.c
index ba5a79d..aef366e 100644
--- a/tests/check_datetime_parser.c
+++ b/tests/check_datetime_parser.c
@@ -24,7 +24,7 @@
static void
test_convert_datetime(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(err);
@@ -36,7 +36,7 @@ test_convert_datetime(void **state)
static void
test_convert_datetime_implicit_seconds(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12:13",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(err);
@@ -48,7 +48,7 @@ test_convert_datetime_implicit_seconds(void **state)
static void
test_convert_datetime_implicit_minutes(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(err);
@@ -60,7 +60,7 @@ test_convert_datetime_implicit_minutes(void **state)
static void
test_convert_datetime_implicit_hours(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(err);
@@ -72,529 +72,529 @@ test_convert_datetime_implicit_hours(void **state)
static void
test_convert_datetime_invalid_formats(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("20", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '20', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("201", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '201', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-1", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-1', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-11", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-11-", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-11-3", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-3', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-11-30 ", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-30 ', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-11-30 1", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-30 1', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-11-30 12:1", "%b %d, %Y, %I:%M:%S %p GMT",
&err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-30 12:1', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
err = NULL;
dt = blogc_convert_datetime("2010-11-30 12:13:1", "%b %d, %Y, %I:%M:%S %p GMT",
&err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-30 12:13:1', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
"'yyyy-mm-dd'.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_1st_year(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("a010-11-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of year. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_2nd_year(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2a10-11-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of year. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_3rd_year(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("20a0-11-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid third digit of year. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_4th_year(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("201a-11-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid fourth digit of year. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_year(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("1899-11-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid year. Found 1899, must be >= 1900.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_1st_hyphen(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010 11-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between year and month. Found ' ', must be '-'.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_1st_month(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-a1-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of month. Found 'a', must be integer >= 0 and <= 1.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_2nd_month(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-1a-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of month. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_month(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-13-30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid month. Found 13, must be >= 1 and <= 12.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_2nd_hyphen(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11 30 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between month and day. Found ' ', must be '-'.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_1st_day(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-a0 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of day. Found 'a', must be integer >= 0 and <= 3.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_2nd_day(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-3a 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of day. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_day(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-12-32 12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid day. Found 32, must be >= 1 and <= 31.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_space(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30-12:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between date and time. Found '-', must be ' ' "
"(empty space).");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_1st_hours(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 a2:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of hours. Found 'a', must be integer >= 0 and <= 2.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_2nd_hours(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 1a:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of hours. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_hours(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-12-30 24:13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid hours. Found 24, must be >= 0 and <= 23.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_1st_colon(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12 13:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between hours and minutes. Found ' ', must be ':'.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_1st_minutes(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12:a3:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of minutes. Found 'a', must be integer >= 0 and <= 5.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_2nd_minutes(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12:1a:14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of minutes. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_2nd_colon(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12:13 14",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between minutes and seconds. Found ' ', must be ':'.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_1st_seconds(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12:13:a4",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of seconds. Found 'a', must be integer >= 0 and <= 6.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_2nd_seconds(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-11-30 12:13:1a",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of seconds. Found 'a', must be integer >= 0 and <= 9.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_seconds(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-12-30 12:13:69",
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid seconds. Found 69, must be >= 0 and <= 60.");
- blogc_error_free(err);
+ sb_error_free(err);
}
static void
test_convert_datetime_invalid_format_long(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
char *dt = blogc_convert_datetime("2010-12-30 12:13:14",
"bovhsuhxwybfrxoluiejaoqpmoylgvkrjtnuntmcgtupwabexkapnklvkwmddmplfqopvb"
"yjsiimtfdeveeeayqvvnthimbqotumngxxenurxhsvyaftwsfdtxqnjluvtcwfkomfffrk"
@@ -613,7 +613,7 @@ test_convert_datetime_invalid_format_long(void **state)
"jgipsincitulscikxviaruryfraeqssykeftcphtndlfhdxokg", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
+ assert_int_equal(err->code, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Failed to format DATE variable, FORMAT is too long: "
"bovhsuhxwybfrxoluiejaoqpmoylgvkrjtnuntmcgtupwabexkapnklvkwmddmplfqopvb"
@@ -631,7 +631,7 @@ test_convert_datetime_invalid_format_long(void **state)
"uaeruwnphdjonqagjatjladqhvlxppyaqgvwpjqggnsccmkjvbxqykaejvgeajqpitkwsq"
"gmjiaopomnnlewidhgbgqlblotrnuyokspuvbckqhwnhmgcwyyitmlelnehdvclojvyswj"
"jgipsincitulscikxviaruryfraeqssykeftcphtndlfhdxokg");
- blogc_error_free(err);
+ sb_error_free(err);
}
diff --git a/tests/check_error.c b/tests/check_error.c
index 4effb08..7fc3c3e 100644
--- a/tests/check_error.c
+++ b/tests/check_error.c
@@ -22,22 +22,22 @@
static void
test_error_new(void **state)
{
- blogc_error_t *error = blogc_error_new(1, "bola %s");
+ sb_error_t *error = sb_error_new(1, "bola %s");
assert_non_null(error);
- assert_int_equal(error->type, 1);
+ assert_int_equal(error->code, 1);
assert_string_equal(error->msg, "bola %s");
- blogc_error_free(error);
+ sb_error_free(error);
}
static void
test_error_new_printf(void **state)
{
- blogc_error_t *error = blogc_error_new_printf(2, "bola %s", "guda");
+ sb_error_t *error = sb_error_new_printf(2, "bola %s", "guda");
assert_non_null(error);
- assert_int_equal(error->type, 2);
+ assert_int_equal(error->code, 2);
assert_string_equal(error->msg, "bola guda");
- blogc_error_free(error);
+ sb_error_free(error);
}
@@ -45,32 +45,32 @@ static void
test_error_parser(void **state)
{
const char *a = "bola\nguda\nchunda\n";
- blogc_error_t *error = blogc_error_parser(1, a, strlen(a), 11, "asd %d", 10);
+ sb_error_t *error = blogc_error_parser(1, a, strlen(a), 11, "asd %d", 10);
assert_non_null(error);
- assert_int_equal(error->type, 1);
+ assert_int_equal(error->code, 1);
assert_string_equal(error->msg,
"asd 10\nError occurred near line 3, position 2: chunda");
- blogc_error_free(error);
+ sb_error_free(error);
a = "bola\nguda\nchunda";
error = blogc_error_parser(1, a, strlen(a), 11, "asd %d", 10);
assert_non_null(error);
- assert_int_equal(error->type, 1);
+ assert_int_equal(error->code, 1);
assert_string_equal(error->msg,
"asd 10\nError occurred near line 3, position 2: chunda");
- blogc_error_free(error);
+ sb_error_free(error);
a = "bola\nguda\nchunda";
error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10);
assert_non_null(error);
- assert_int_equal(error->type, 1);
+ assert_int_equal(error->code, 1);
assert_string_equal(error->msg,
"asd 10\nError occurred near line 1, position 1: bola");
- blogc_error_free(error);
+ sb_error_free(error);
a = "";
error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10);
assert_non_null(error);
- assert_int_equal(error->type, 1);
+ assert_int_equal(error->code, 1);
assert_string_equal(error->msg, "asd 10");
- blogc_error_free(error);
+ sb_error_free(error);
}
@@ -78,26 +78,26 @@ static void
test_error_parser_crlf(void **state)
{
const char *a = "bola\r\nguda\r\nchunda\r\n";
- blogc_error_t *error = blogc_error_parser(1, a, strlen(a), 13, "asd %d", 10);
+ sb_error_t *error = blogc_error_parser(1, a, strlen(a), 13, "asd %d", 10);
assert_non_null(error);
- assert_int_equal(error->type, 1);
+ assert_int_equal(error->code, 1);
assert_string_equal(error->msg,
"asd 10\nError occurred near line 3, position 2: chunda");
- blogc_error_free(error);
+ sb_error_free(error);
a = "bola\r\nguda\r\nchunda";
error = blogc_error_parser(1, a, strlen(a), 13, "asd %d", 10);
assert_non_null(error);
- assert_int_equal(error->type, 1);
+ assert_int_equal(error->code, 1);
assert_string_equal(error->msg,
"asd 10\nError occurred near line 3, position 2: chunda");
- blogc_error_free(error);
+ sb_error_free(error);
a = "bola\r\nguda\r\nchunda";
error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10);
assert_non_null(error);
- assert_int_equal(error->type, 1);
+ assert_int_equal(error->code, 1);
assert_string_equal(error->msg,
"asd 10\nError occurred near line 1, position 1: bola");
- blogc_error_free(error);
+ sb_error_free(error);
}
diff --git a/tests/check_loader.c b/tests/check_loader.c
index 52bd056..0db6194 100644
--- a/tests/check_loader.c
+++ b/tests/check_loader.c
@@ -52,7 +52,7 @@ test_get_filename(void **state)
char*
-__wrap_blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err)
+__wrap_blogc_file_get_contents(const char *path, size_t *len, sb_error_t **err)
{
assert_null(*err);
const char *_path = mock_type(const char*);
@@ -78,7 +78,7 @@ __wrap_blogc_fprintf(FILE *stream, const char *format, ...)
static void
test_template_parse_from_file(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
will_return(__wrap_blogc_file_get_contents, "bola");
will_return(__wrap_blogc_file_get_contents, sb_strdup("{{ BOLA }}\n"));
sb_slist_t *l = blogc_template_parse_from_file("bola", &err);
@@ -92,7 +92,7 @@ test_template_parse_from_file(void **state)
static void
test_template_parse_from_file_null(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
will_return(__wrap_blogc_file_get_contents, "bola");
will_return(__wrap_blogc_file_get_contents, NULL);
sb_slist_t *l = blogc_template_parse_from_file("bola", &err);
@@ -104,7 +104,7 @@ test_template_parse_from_file_null(void **state)
static void
test_source_parse_from_file(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
will_return(__wrap_blogc_file_get_contents, "bola.txt");
will_return(__wrap_blogc_file_get_contents, sb_strdup(
"ASD: 123\n"
@@ -126,7 +126,7 @@ test_source_parse_from_file(void **state)
static void
test_source_parse_from_file_null(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
will_return(__wrap_blogc_file_get_contents, "bola.txt");
will_return(__wrap_blogc_file_get_contents, NULL);
sb_trie_t *t = blogc_source_parse_from_file("bola.txt", &err);
@@ -156,7 +156,7 @@ test_source_parse_from_files(void **state)
"DATE: 2003-02-03 04:05:06\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -200,7 +200,7 @@ test_source_parse_from_files_filter_by_tag(void **state)
"DATE: 2003-02-03 04:05:06\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -268,7 +268,7 @@ test_source_parse_from_files_filter_by_page(void **state)
"DATE: 2007-02-03 04:05:06\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -346,7 +346,7 @@ test_source_parse_from_files_filter_by_page2(void **state)
"DATE: 2007-02-03 04:05:06\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -425,7 +425,7 @@ test_source_parse_from_files_filter_by_page3(void **state)
"DATE: 2007-02-03 04:05:06\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -508,7 +508,7 @@ test_source_parse_from_files_filter_by_page_and_tag(void **state)
"TAGS: yay chunda\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -588,7 +588,7 @@ test_source_parse_from_files_filter_by_page_invalid(void **state)
"DATE: 2007-02-03 04:05:06\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -666,7 +666,7 @@ test_source_parse_from_files_filter_by_page_invalid2(void **state)
"DATE: 2007-02-03 04:05:06\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -711,7 +711,7 @@ test_source_parse_from_files_without_all_dates(void **state)
"DATE: 2003-02-03 04:05:06\n"
"--------\n"
"bola"));
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
s = sb_slist_append(s, sb_strdup("bola1.txt"));
s = sb_slist_append(s, sb_strdup("bola2.txt"));
@@ -734,7 +734,7 @@ test_source_parse_from_files_without_all_dates(void **state)
static void
test_source_parse_from_files_null(void **state)
{
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *s = NULL;
sb_trie_t *c = sb_trie_new(free);
sb_slist_t *t = blogc_source_parse_from_files(c, s, &err);
diff --git a/tests/check_renderer.c b/tests/check_renderer.c
index e863360..d71f045 100644
--- a/tests/check_renderer.c
+++ b/tests/check_renderer.c
@@ -46,7 +46,7 @@ create_sources(unsigned int count)
"ahahahahahahahaha3",
};
assert_false(count > 3);
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = NULL;
for (unsigned int i = 0; i < count; i++) {
l = sb_slist_append(l, blogc_source_parse(s[i], strlen(s[i]), &err));
@@ -78,7 +78,7 @@ test_render_entry(void **state)
"{% if GUDA <= \"zxc\" %}LOL4{% endif %}\n"
"{% foreach TAGS %}lol {{ FOREACH_ITEM }} haha {% endforeach %}\n"
"{% foreach TAGS_ASD %}yay{% endforeach %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -125,7 +125,7 @@ test_render_listing(void **state)
"{% foreach TAGS %}lol {{ FOREACH_ITEM }} haha {% endforeach %}\n"
"{% foreach TAGS_ASD %}yay{% endforeach %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -173,7 +173,7 @@ test_render_listing_empty(void **state)
"bola: {% ifdef BOLA %}{{ BOLA }}{% endif %}\n"
"{% foreach TAGS %}lol {{ FOREACH_ITEM }} haha {% endforeach %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -200,7 +200,7 @@ test_render_ifdef(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -229,7 +229,7 @@ test_render_ifdef2(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -260,7 +260,7 @@ test_render_ifdef3(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -293,7 +293,7 @@ test_render_ifndef(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -327,7 +327,7 @@ test_render_if_eq(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -362,7 +362,7 @@ test_render_if_neq(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -397,7 +397,7 @@ test_render_if_lt(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -432,7 +432,7 @@ test_render_if_gt(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -469,7 +469,7 @@ test_render_if_lt_eq(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -508,7 +508,7 @@ test_render_if_gt_eq(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -539,7 +539,7 @@ test_render_foreach(void **state)
"{% block entry %}\n"
"{% foreach TAGS %} {{ FOREACH_ITEM }} {% endforeach %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -564,7 +564,7 @@ test_render_foreach_if(void **state)
"{% foreach TAGS %} {% if FOREACH_ITEM == \"bar\" %}{{ FOREACH_ITEM }}"
"{% endif %} {% endforeach %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -595,7 +595,7 @@ test_render_outside_block(void **state)
"{% ifdef GUDA %}bola{% endif %}\n"
"{{ BOLA }}\n"
"{% ifndef CHUNDA %}lol{% endif %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -628,7 +628,7 @@ test_render_prefer_local_variable(void **state)
"{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -664,7 +664,7 @@ test_render_respect_variable_scope(void **state)
"{% ifdef LOL %}{{ LOL }}{% endif %}\n"
"{% ifdef BOLA %}{{ BOLA }}{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
@@ -696,7 +696,7 @@ test_render_ifcount_bug(void **state)
"{% ifdef ASD %}ASD{% endif %}\n"
"{% endif %}\n"
"{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c
index a16a923..fba997a 100644
--- a/tests/check_source_parser.c
+++ b/tests/check_source_parser.c
@@ -30,7 +30,7 @@ test_source_parse(void **state)
"# This is a test\n"
"\n"
"bola\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(source);
@@ -61,7 +61,7 @@ test_source_parse_crlf(void **state)
"# This is a test\r\n"
"\r\n"
"bola\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(source);
@@ -94,7 +94,7 @@ test_source_parse_with_spaces(void **state)
"# This is a test\n"
"\n"
"bola\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(source);
@@ -130,7 +130,7 @@ test_source_parse_with_excerpt(void **state)
"\n"
"guda\n"
"yay";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(source);
@@ -162,13 +162,13 @@ static void
test_source_parse_config_empty(void **state)
{
const char *a = "";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg, "Your source file is empty.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -177,14 +177,14 @@ static void
test_source_parse_config_invalid_key(void **state)
{
const char *a = "bola: guda";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"Can't find a configuration key or the content separator.\n"
"Error occurred near line 1, position 1: bola: guda");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -193,14 +193,14 @@ static void
test_source_parse_config_no_key(void **state)
{
const char *a = "BOLa";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"Invalid configuration key.\n"
"Error occurred near line 1, position 4: BOLa");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -209,14 +209,14 @@ static void
test_source_parse_config_no_key2(void **state)
{
const char *a = "BOLA";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"Your last configuration key is missing ':' and the value\n"
"Error occurred near line 1, position 5: BOLA");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -225,15 +225,15 @@ static void
test_source_parse_config_no_value(void **state)
{
const char *a = "BOLA:\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"Configuration value not provided for 'BOLA'.\n"
"Error occurred near line 1, position 6: BOLA:");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -242,15 +242,15 @@ static void
test_source_parse_config_no_value2(void **state)
{
const char *a = "BOLA:";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"Configuration value not provided for 'BOLA'.\n"
"Error occurred near line 1, position 6: BOLA:");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -259,15 +259,15 @@ static void
test_source_parse_config_reserved_name(void **state)
{
const char *a = "FILENAME: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'FILENAME' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -276,15 +276,15 @@ static void
test_source_parse_config_reserved_name2(void **state)
{
const char *a = "CONTENT: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'CONTENT' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -293,15 +293,15 @@ static void
test_source_parse_config_reserved_name3(void **state)
{
const char *a = "DATE_FORMATTED: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'DATE_FORMATTED' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -310,15 +310,15 @@ static void
test_source_parse_config_reserved_name4(void **state)
{
const char *a = "DATE_FIRST_FORMATTED: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'DATE_FIRST_FORMATTED' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -327,15 +327,15 @@ static void
test_source_parse_config_reserved_name5(void **state)
{
const char *a = "DATE_LAST_FORMATTED: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'DATE_LAST_FORMATTED' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -344,15 +344,15 @@ static void
test_source_parse_config_reserved_name6(void **state)
{
const char *a = "PAGE_FIRST: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'PAGE_FIRST' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -361,15 +361,15 @@ static void
test_source_parse_config_reserved_name7(void **state)
{
const char *a = "PAGE_PREVIOUS: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'PAGE_PREVIOUS' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -378,15 +378,15 @@ static void
test_source_parse_config_reserved_name8(void **state)
{
const char *a = "PAGE_CURRENT: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'PAGE_CURRENT' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -395,15 +395,15 @@ static void
test_source_parse_config_reserved_name9(void **state)
{
const char *a = "PAGE_NEXT: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'PAGE_NEXT' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -412,15 +412,15 @@ static void
test_source_parse_config_reserved_name10(void **state)
{
const char *a = "PAGE_LAST: asd\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'PAGE_LAST' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -429,15 +429,15 @@ static void
test_source_parse_config_reserved_name11(void **state)
{
const char *a = "BLOGC_VERSION: 1.0\r\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"'BLOGC_VERSION' variable is forbidden in source files. It will be set "
"for you by the compiler.");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -446,15 +446,15 @@ static void
test_source_parse_config_value_no_line_ending(void **state)
{
const char *a = "BOLA: asd";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"No line ending after the configuration value for 'BOLA'.\n"
"Error occurred near line 1, position 10: BOLA: asd");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
@@ -463,15 +463,15 @@ static void
test_source_parse_invalid_separator(void **state)
{
const char *a = "BOLA: asd\n---#";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(source);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_SOURCE_PARSER);
assert_string_equal(err->msg,
"Invalid content separator. Must be more than one '-' characters.\n"
"Error occurred near line 2, position 4: ---#");
- blogc_error_free(err);
+ sb_error_free(err);
sb_trie_free(source);
}
diff --git a/tests/check_template_parser.c b/tests/check_template_parser.c
index ed4328b..9419607 100644
--- a/tests/check_template_parser.c
+++ b/tests/check_template_parser.c
@@ -63,7 +63,7 @@ test_template_parse(void **state)
"{% block listing_once %}asd{% endblock %}\n"
"{%- foreach BOLA %}hahaha{% endforeach %}\n"
"{% if BOLA == \"1\\\"0\" %}aee{% endif %}";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(stmts);
@@ -143,7 +143,7 @@ test_template_parse_crlf(void **state)
"{% block listing_once %}asd{% endblock %}\r\n"
"{%- foreach BOLA %}hahaha{% endforeach %}\r\n"
"{% if BOLA == \"1\\\"0\" %}aee{% endif %}";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(stmts);
@@ -231,7 +231,7 @@ test_template_parse_html(void **state)
" {% block listing_once %}</ul>{% endblock %}\n"
" </body>\n"
"</html>\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(stmts);
@@ -341,7 +341,7 @@ test_template_parse_ifdef_and_var_outside_block(void **state)
"{% ifdef GUDA %}bola{% endif %}\n"
"{{ BOLA }}\n"
"{% ifndef CHUNDA %}{{ CHUNDA }}{% endif %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(stmts);
@@ -372,35 +372,35 @@ static void
test_template_parse_invalid_block_start(void **state)
{
const char *a = "{% ASD %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must begin with lowercase letter.\n"
"Error occurred near line 1, position 4: {% ASD %}");
- blogc_error_free(err);
+ sb_error_free(err);
a = "{%-- block entry %}\n";
err = NULL;
stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Duplicated whitespace cleaner before statement.\n"
"Error occurred near line 1, position 4: {%-- block entry %}");
- blogc_error_free(err);
+ sb_error_free(err);
a = "{% block entry --%}\n";
err = NULL;
stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Duplicated whitespace cleaner after statement.\n"
"Error occurred near line 1, position 17: {% block entry --%}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -410,15 +410,15 @@ test_template_parse_invalid_block_nested(void **state)
const char *a =
"{% block entry %}\n"
"{% block listing %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Blocks can't be nested.\n"
"Error occurred near line 2, position 9: {% block listing %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -428,15 +428,15 @@ test_template_parse_invalid_foreach_nested(void **state)
const char *a =
"{% foreach A %}\n"
"{% foreach B %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'foreach' statements can't be nested.\n"
"Error occurred near line 2, position 11: {% foreach B %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -444,15 +444,15 @@ static void
test_template_parse_invalid_block_not_open(void **state)
{
const char *a = "{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endblock' statement without an open 'block' statement.\n"
"Error occurred near line 1, position 12: {% endblock %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -460,16 +460,16 @@ static void
test_template_parse_invalid_endif_not_open(void **state)
{
const char *a = "{% block listing %}{% endif %}{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endif' statement without an open 'ifdef' or 'ifndef' statement.\n"
"Error occurred near line 1, position 28: "
"{% block listing %}{% endif %}{% endblock %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -477,15 +477,15 @@ static void
test_template_parse_invalid_endforeach_not_open(void **state)
{
const char *a = "{% endforeach %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endforeach' statement without an open 'foreach' statement.\n"
"Error occurred near line 1, position 14: {% endforeach %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -493,16 +493,16 @@ static void
test_template_parse_invalid_block_name(void **state)
{
const char *a = "{% chunda %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement type: Allowed types are: 'block', 'endblock', 'ifdef', "
"'ifndef', 'endif', 'foreach' and 'endforeach'.\n"
"Error occurred near line 1, position 10: {% chunda %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -510,15 +510,15 @@ static void
test_template_parse_invalid_block_type_start(void **state)
{
const char *a = "{% block ENTRY %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid block syntax. Must begin with lowercase letter.\n"
"Error occurred near line 1, position 10: {% block ENTRY %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -526,15 +526,15 @@ static void
test_template_parse_invalid_block_type(void **state)
{
const char *a = "{% block chunda %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid block type. Allowed types are: 'entry', 'listing' and 'listing_once'.\n"
"Error occurred near line 1, position 16: {% block chunda %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -542,16 +542,16 @@ static void
test_template_parse_invalid_ifdef_start(void **state)
{
const char *a = "{% block entry %}{% ifdef guda %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must begin with uppercase letter.\n"
"Error occurred near line 1, position 27: "
"{% block entry %}{% ifdef guda %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -559,16 +559,16 @@ static void
test_template_parse_invalid_foreach_start(void **state)
{
const char *a = "{% block entry %}{% foreach guda %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid foreach variable name. Must begin with uppercase letter.\n"
"Error occurred near line 1, position 29: "
"{% block entry %}{% foreach guda %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -576,16 +576,16 @@ static void
test_template_parse_invalid_ifdef_variable(void **state)
{
const char *a = "{% block entry %}{% ifdef BoLA %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must be uppercase letter, number or '_'.\n"
"Error occurred near line 1, position 28: "
"{% block entry %}{% ifdef BoLA %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -593,16 +593,16 @@ static void
test_template_parse_invalid_ifdef_variable2(void **state)
{
const char *a = "{% block entry %}{% ifdef 0123 %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must begin with uppercase letter.\n"
"Error occurred near line 1, position 27: "
"{% block entry %}{% ifdef 0123 %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -610,16 +610,16 @@ static void
test_template_parse_invalid_foreach_variable(void **state)
{
const char *a = "{% block entry %}{% foreach BoLA %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid foreach variable name. Must be uppercase letter, number or '_'.\n"
"Error occurred near line 1, position 30: "
"{% block entry %}{% foreach BoLA %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -627,16 +627,16 @@ static void
test_template_parse_invalid_foreach_variable2(void **state)
{
const char *a = "{% block entry %}{% foreach 0123 %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid foreach variable name. Must begin with uppercase letter.\n"
"Error occurred near line 1, position 29: {% block entry %}"
"{% foreach 0123 %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -644,16 +644,16 @@ static void
test_template_parse_invalid_if_operator(void **state)
{
const char *a = "{% block entry %}{% if BOLA = \"asd\" %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid 'if' operator. Must be '<', '>', '<=', '>=', '==' or '!='.\n"
"Error occurred near line 1, position 29: "
"{% block entry %}{% if BOLA = \"asd\" %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -661,16 +661,16 @@ static void
test_template_parse_invalid_if_operand(void **state)
{
const char *a = "{% block entry %}{% if BOLA == asd %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid 'if' operand. Must be double-quoted static string or variable.\n"
"Error occurred near line 1, position 32: "
"{% block entry %}{% if BOLA == asd %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -678,16 +678,16 @@ static void
test_template_parse_invalid_if_operand2(void **state)
{
const char *a = "{% block entry %}{% if BOLA == \"asd %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Found an open double-quoted string.\n"
"Error occurred near line 1, position 31: "
"{% block entry %}{% if BOLA == \"asd %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -695,16 +695,16 @@ static void
test_template_parse_invalid_if_operand3(void **state)
{
const char *a = "{% block entry %}{% if BOLA == 0123 %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid 'if' operand. Must be double-quoted static string or variable.\n"
"Error occurred near line 1, position 32: "
"{% block entry %}{% if BOLA == 0123 %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -712,15 +712,15 @@ static void
test_template_parse_invalid_block_end(void **state)
{
const char *a = "{% block entry }}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must end with '%}'.\n"
"Error occurred near line 1, position 16: {% block entry }}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -728,16 +728,16 @@ static void
test_template_parse_invalid_variable_name(void **state)
{
const char *a = "{% block entry %}{{ bola }}{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must begin with uppercase letter.\n"
"Error occurred near line 1, position 21: "
"{% block entry %}{{ bola }}{% endblock %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -745,16 +745,16 @@ static void
test_template_parse_invalid_variable_name2(void **state)
{
const char *a = "{% block entry %}{{ Bola }}{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must be uppercase letter, number or '_'.\n"
"Error occurred near line 1, position 22: "
"{% block entry %}{{ Bola }}{% endblock %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -762,16 +762,16 @@ static void
test_template_parse_invalid_variable_name3(void **state)
{
const char *a = "{% block entry %}{{ 0123 }}{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must begin with uppercase letter.\n"
"Error occurred near line 1, position 21: {% block entry %}{{ 0123 }}"
"{% endblock %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -779,16 +779,16 @@ static void
test_template_parse_invalid_variable_end(void **state)
{
const char *a = "{% block entry %}{{ BOLA %}{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must end with '}}'.\n"
"Error occurred near line 1, position 26: "
"{% block entry %}{{ BOLA %}{% endblock %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -796,15 +796,15 @@ static void
test_template_parse_invalid_close(void **state)
{
const char *a = "{% block entry %%\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must end with '}'.\n"
"Error occurred near line 1, position 17: {% block entry %%");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -812,16 +812,16 @@ static void
test_template_parse_invalid_close2(void **state)
{
const char *a = "{% block entry %}{{ BOLA }%{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must end with '}'.\n"
"Error occurred near line 1, position 27: "
"{% block entry %}{{ BOLA }%{% endblock %}");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -829,14 +829,14 @@ static void
test_template_parse_invalid_if_not_closed(void **state)
{
const char *a = "{% block entry %}{% ifdef BOLA %}{% endblock %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg, "1 open 'ifdef' and/or 'ifndef' statements "
"were not closed!");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -844,13 +844,13 @@ static void
test_template_parse_invalid_block_not_closed(void **state)
{
const char *a = "{% block entry %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg, "An open block was not closed!");
- blogc_error_free(err);
+ sb_error_free(err);
}
@@ -858,13 +858,13 @@ static void
test_template_parse_invalid_foreach_not_closed(void **state)
{
const char *a = "{% foreach ASD %}\n";
- blogc_error_t *err = NULL;
+ sb_error_t *err = NULL;
sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
assert_null(stmts);
- assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
+ assert_int_equal(err->code, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg, "An open 'foreach' statement was not closed!");
- blogc_error_free(err);
+ sb_error_free(err);
}