summaryrefslogtreecommitdiff
path: root/src/tests/elementary/elm_code_test_line.c
blob: 34667b75533fbad8404230bf6f0acccbeb64e578 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#include "elm_suite.h"
#include "Elementary.h"

EFL_START_TEST(elm_code_line_create_test)
{
   Elm_Code *code;
   Elm_Code_File *file;
   Elm_Code_Line *line;

   char *args[] = { "exe" };
   elm_init(1, args);
   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);
   elm_shutdown();
}
EFL_END_TEST

EFL_START_TEST(elm_code_line_token_count_test)
{
   Elm_Code *code;
   Elm_Code_File *file;
   Elm_Code_Line *line;

   char *args[] = { "exe" };
   elm_init(1, args);
   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);
   elm_shutdown();
}
EFL_END_TEST

EFL_START_TEST(elm_code_line_split_test)
{
   Elm_Code *code;
   Elm_Code_File *file;
   Elm_Code_Line *line, *newline;

   char *args[] = { "exe" };
   elm_init(1, args);
   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);
   elm_shutdown();
}
EFL_END_TEST

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);
   tcase_add_test(tc, elm_code_line_split_test);
}