2015-04-12 09:25:20 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2016-06-02 17:19:08 -07:00
|
|
|
# include "elementary_config.h"
|
2015-04-12 09:25:20 -07:00
|
|
|
#endif
|
|
|
|
|
2016-06-02 17:19:08 -07:00
|
|
|
#include "elm_suite.h"
|
|
|
|
#include "Elementary.h"
|
2015-04-12 09:25:20 -07:00
|
|
|
|
2019-01-28 10:42:56 -08:00
|
|
|
EFL_START_TEST(elm_code_line_create_test)
|
2015-04-12 09:25:20 -07:00
|
|
|
{
|
|
|
|
Elm_Code *code;
|
|
|
|
Elm_Code_File *file;
|
|
|
|
Elm_Code_Line *line;
|
|
|
|
|
2018-03-06 06:43:06 -08:00
|
|
|
char *args[] = { "exe" };
|
|
|
|
elm_init(1, args);
|
2015-04-12 09:25:20 -07:00
|
|
|
code = elm_code_create();
|
|
|
|
file = elm_code_file_new(code);
|
|
|
|
|
|
|
|
elm_code_file_line_append(file, "a test string...", 16, NULL);
|
|
|
|
line = elm_code_file_line_get(file, 1);
|
|
|
|
|
|
|
|
ck_assert(!!line);
|
|
|
|
|
|
|
|
elm_code_free(code);
|
2016-06-02 17:19:08 -07:00
|
|
|
elm_shutdown();
|
2015-04-12 09:25:20 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2015-04-12 09:25:20 -07:00
|
|
|
|
2019-01-28 10:42:56 -08:00
|
|
|
EFL_START_TEST(elm_code_line_token_count_test)
|
2015-04-12 09:25:20 -07:00
|
|
|
{
|
|
|
|
Elm_Code *code;
|
|
|
|
Elm_Code_File *file;
|
|
|
|
Elm_Code_Line *line;
|
|
|
|
|
2018-03-06 06:43:06 -08:00
|
|
|
char *args[] = { "exe" };
|
|
|
|
elm_init(1, args);
|
2015-04-12 09:25:20 -07:00
|
|
|
code = elm_code_create();
|
|
|
|
file = elm_code_file_new(code);
|
|
|
|
|
|
|
|
elm_code_file_line_append(file, "a test string...", 16, NULL);
|
|
|
|
line = elm_code_file_line_get(file, 1);
|
|
|
|
|
|
|
|
ck_assert_int_eq(0, eina_list_count(line->tokens));
|
|
|
|
elm_code_line_token_add(line, 2, 5, 1, ELM_CODE_TOKEN_TYPE_COMMENT);
|
|
|
|
ck_assert_int_eq(1, eina_list_count(line->tokens));
|
|
|
|
elm_code_line_tokens_clear(line);
|
|
|
|
ck_assert_int_eq(0, eina_list_count(line->tokens));
|
|
|
|
|
|
|
|
elm_code_free(code);
|
2016-06-02 17:19:08 -07:00
|
|
|
elm_shutdown();
|
2015-04-12 09:25:20 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2015-04-12 09:25:20 -07:00
|
|
|
|
2019-01-28 10:42:56 -08:00
|
|
|
EFL_START_TEST(elm_code_line_split_test)
|
2015-04-19 07:00:10 -07:00
|
|
|
{
|
|
|
|
Elm_Code *code;
|
|
|
|
Elm_Code_File *file;
|
|
|
|
Elm_Code_Line *line, *newline;
|
|
|
|
|
2018-03-06 06:43:06 -08:00
|
|
|
char *args[] = { "exe" };
|
|
|
|
elm_init(1, args);
|
2015-04-19 07:00:10 -07:00
|
|
|
code = elm_code_create();
|
|
|
|
file = elm_code_file_new(code);
|
|
|
|
|
|
|
|
elm_code_file_line_append(file, "line1line2", 10, NULL);
|
|
|
|
line = elm_code_file_line_get(file, 1);
|
|
|
|
ck_assert_int_eq(1, elm_code_file_lines_get(file));
|
|
|
|
ck_assert_int_eq(10, line->length);
|
|
|
|
|
|
|
|
elm_code_line_split_at(line, 5);
|
|
|
|
ck_assert_int_eq(2, elm_code_file_lines_get(file));
|
|
|
|
newline = elm_code_file_line_get(file, 2);
|
|
|
|
ck_assert_int_eq(5, line->length);
|
|
|
|
ck_assert_int_eq(5, newline->length);
|
2016-06-02 17:19:08 -07:00
|
|
|
elm_shutdown();
|
2015-04-19 07:00:10 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2015-04-19 07:00:10 -07:00
|
|
|
|
2015-04-12 09:25:20 -07:00
|
|
|
void elm_code_test_line(TCase *tc)
|
|
|
|
{
|
|
|
|
tcase_add_test(tc, elm_code_line_create_test);
|
|
|
|
tcase_add_test(tc, elm_code_line_token_count_test);
|
2015-04-19 07:00:10 -07:00
|
|
|
tcase_add_test(tc, elm_code_line_split_test);
|
2015-04-12 09:25:20 -07:00
|
|
|
}
|