2014-11-16 15:52:41 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "elm_code_suite.h"
|
|
|
|
#include "elm_code_parse.h"
|
|
|
|
|
|
|
|
static int line_calls, file_calls;
|
|
|
|
|
2015-02-23 16:32:40 -08:00
|
|
|
static void _parser_line_callback(Elm_Code_Line *line EINA_UNUSED, void *data EINA_UNUSED)
|
2014-11-16 15:52:41 -08:00
|
|
|
{
|
|
|
|
line_calls++;
|
|
|
|
}
|
|
|
|
|
2015-02-23 16:32:40 -08:00
|
|
|
static void _parser_file_callback(Elm_Code_File *file EINA_UNUSED, void *data EINA_UNUSED)
|
2014-11-16 15:52:41 -08:00
|
|
|
{
|
|
|
|
file_calls++;
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST (elm_code_parse_hook_memory_test)
|
|
|
|
{
|
|
|
|
Elm_Code *code;
|
|
|
|
Elm_Code_File *file;
|
|
|
|
|
|
|
|
line_calls = 0;
|
|
|
|
file_calls = 0;
|
|
|
|
|
|
|
|
code = elm_code_create();
|
|
|
|
file = elm_code_file_new(code);
|
|
|
|
|
2015-02-23 16:32:40 -08:00
|
|
|
elm_code_parser_add(code, _parser_line_callback, _parser_file_callback, NULL);
|
2015-02-14 15:14:06 -08:00
|
|
|
elm_code_file_line_append(file, "some \"test content\" for parsing", 31, NULL);
|
2014-11-16 15:52:41 -08:00
|
|
|
|
|
|
|
ck_assert_int_eq(1, line_calls);
|
|
|
|
ck_assert_int_eq(0, file_calls);
|
|
|
|
|
|
|
|
elm_code_free(code);
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST (elm_code_parse_hook_file_test)
|
|
|
|
{
|
|
|
|
Elm_Code *code;
|
|
|
|
Elm_Code_File *file;
|
2015-02-06 15:45:50 -08:00
|
|
|
char *path = TESTS_DIR "testfile.txt";
|
2014-11-16 15:52:41 -08:00
|
|
|
|
|
|
|
line_calls = 0;
|
|
|
|
file_calls = 0;
|
|
|
|
|
|
|
|
code = elm_code_create();
|
|
|
|
|
2015-02-23 16:32:40 -08:00
|
|
|
elm_code_parser_add(code, _parser_line_callback, _parser_file_callback, NULL);
|
2014-11-16 15:52:41 -08:00
|
|
|
file = elm_code_file_open(code, path);
|
|
|
|
|
|
|
|
ck_assert_int_eq(4, line_calls);
|
|
|
|
ck_assert_int_eq(1, file_calls);
|
|
|
|
|
|
|
|
elm_code_file_close(file);
|
|
|
|
elm_code_free(code);
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-04-19 17:21:03 -07:00
|
|
|
START_TEST (elm_code_parse_todo_test)
|
|
|
|
{
|
|
|
|
Elm_Code *code;
|
|
|
|
Elm_Code_File *file;
|
|
|
|
Elm_Code_Line *line;
|
|
|
|
|
|
|
|
elm_code_init();
|
|
|
|
|
|
|
|
code = elm_code_create();
|
|
|
|
elm_code_parser_standard_add(code, ELM_CODE_PARSER_STANDARD_TODO);
|
|
|
|
file = elm_code_file_new(code);
|
|
|
|
|
|
|
|
elm_code_file_line_append(file, "xxx TODO line", 13, NULL);
|
|
|
|
line = elm_code_file_line_get(file, 1);
|
|
|
|
ck_assert_int_eq(ELM_CODE_STATUS_TYPE_TODO, line->status);
|
|
|
|
|
|
|
|
elm_code_line_text_set(line, "FIXME too", 9);
|
|
|
|
ck_assert_int_eq(ELM_CODE_STATUS_TYPE_TODO, line->status);
|
|
|
|
|
|
|
|
elm_code_line_text_set(line, "TOFIX", 5);
|
|
|
|
ck_assert_int_eq(ELM_CODE_STATUS_TYPE_DEFAULT, line->status);
|
|
|
|
elm_code_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-11-16 15:52:41 -08:00
|
|
|
void elm_code_test_parse(TCase *tc)
|
|
|
|
{
|
|
|
|
tcase_add_test(tc, elm_code_parse_hook_memory_test);
|
|
|
|
tcase_add_test(tc, elm_code_parse_hook_file_test);
|
2015-04-19 17:21:03 -07:00
|
|
|
tcase_add_test(tc, elm_code_parse_todo_test);
|
2014-11-16 15:52:41 -08:00
|
|
|
}
|
|
|
|
|