summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2016-11-28 01:01:35 +0000
committerAndy Williams <andy@andywilliams.me>2016-11-28 01:01:35 +0000
commit60cd21979228482a6245f03d8110aafa2810f5d6 (patch)
tree16bc1b379e225fe111cc3842ec19316d47e292e8
parentc5181470c169874026bd7836dc2aa48c5b0d75e7 (diff)
tests: Update for elm_code indent changes
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/tests/elementary/elm_code_test_indent.c43
-rw-r--r--src/tests/elementary/elm_code_test_text.c42
-rw-r--r--src/tests/elementary/elm_suite.c19
-rw-r--r--src/tests/elementary/elm_suite.h1
5 files changed, 55 insertions, 51 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 480f683..ee6254b 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -1318,6 +1318,7 @@ tests_elementary_elm_suite_SOURCES = \
1318 tests/elementary/elm_code_test_line.c \ 1318 tests/elementary/elm_code_test_line.c \
1319 tests/elementary/elm_code_test_parse.c \ 1319 tests/elementary/elm_code_test_parse.c \
1320 tests/elementary/elm_code_test_text.c \ 1320 tests/elementary/elm_code_test_text.c \
1321 tests/elementary/elm_code_test_indent.c \
1321 tests/elementary/elm_code_test_widget.c \ 1322 tests/elementary/elm_code_test_widget.c \
1322 tests/elementary/elm_code_test_widget_text.c \ 1323 tests/elementary/elm_code_test_widget_text.c \
1323 tests/elementary/elm_code_test_widget_selection.c \ 1324 tests/elementary/elm_code_test_widget_selection.c \
diff --git a/src/tests/elementary/elm_code_test_indent.c b/src/tests/elementary/elm_code_test_indent.c
new file mode 100644
index 0000000..cf03fa0
--- /dev/null
+++ b/src/tests/elementary/elm_code_test_indent.c
@@ -0,0 +1,43 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define ELM_INTERNAL_API_ARGESFSDFEFC
6
7#include "elm_suite.h"
8#include "Elementary.h"
9#include "elm_code_indent.h"
10
11START_TEST (elm_code_indent_whitespace_test)
12{
13 const char *str;
14
15 str = elm_code_line_indent_get("", 0);
16 ck_assert_str_eq("", str);
17 str = elm_code_line_indent_get(" ", 2);
18 ck_assert_str_eq(" ", str);
19 str = elm_code_line_indent_get("\t", 1);
20 ck_assert_str_eq("\t", str);
21 str = elm_code_line_indent_get("\t ", 3);
22 ck_assert_str_eq("\t ", str);
23}
24END_TEST
25
26START_TEST (elm_code_indent_comments_test)
27{
28 const char *str;
29
30 str = elm_code_line_indent_get(" /**", 4);
31 ck_assert_str_eq(" * ", str);
32 str = elm_code_line_indent_get(" * ", 4);
33 ck_assert_str_eq(" * ", str);
34 str = elm_code_line_indent_get("\t//", 3);
35 ck_assert_str_eq("\t//", str);
36}
37END_TEST
38
39void elm_code_test_indent(TCase *tc)
40{
41 tcase_add_test(tc, elm_code_indent_whitespace_test);
42 tcase_add_test(tc, elm_code_indent_comments_test);
43}
diff --git a/src/tests/elementary/elm_code_test_text.c b/src/tests/elementary/elm_code_test_text.c
index fb198c9..dfff80f 100644
--- a/src/tests/elementary/elm_code_test_text.c
+++ b/src/tests/elementary/elm_code_test_text.c
@@ -115,46 +115,6 @@ START_TEST (elm_code_text_newline_position_test)
115} 115}
116END_TEST 116END_TEST
117 117
118START_TEST (elm_code_text_leading_whitespace_test)
119{
120 const char *text;
121
122 elm_init(1, NULL);
123 text = "testing";
124 ck_assert_int_eq(0, elm_code_text_leading_whitespace_length(text, strlen(text)));
125
126 text = " spaces";
127 ck_assert_int_eq(2, elm_code_text_leading_whitespace_length(text, strlen(text)));
128
129 text = "\t\ttabs";
130 ck_assert_int_eq(2, elm_code_text_leading_whitespace_length(text, strlen(text)));
131
132 text = " \t mix";
133 ck_assert_int_eq(3, elm_code_text_leading_whitespace_length(text, strlen(text)));
134 elm_shutdown();
135}
136END_TEST
137
138START_TEST (elm_code_text_trailing_whitespace_test)
139{
140 const char *text;
141
142 elm_init(1, NULL);
143 text = "testing";
144 ck_assert_int_eq(0, elm_code_text_trailing_whitespace_length(text, strlen(text)));
145
146 text = "spaces ";
147 ck_assert_int_eq(2, elm_code_text_trailing_whitespace_length(text, strlen(text)));
148
149 text = "tabs\t\t";
150 ck_assert_int_eq(2, elm_code_text_trailing_whitespace_length(text, strlen(text)));
151
152 text = "mix \t ";
153 ck_assert_int_eq(3, elm_code_text_trailing_whitespace_length(text, strlen(text)));
154 elm_shutdown();
155}
156END_TEST
157
158START_TEST (elm_code_text_is_whitespace_test) 118START_TEST (elm_code_text_is_whitespace_test)
159{ 119{
160 const char *text; 120 const char *text;
@@ -179,7 +139,5 @@ void elm_code_test_text(TCase *tc)
179 tcase_add_test(tc, elm_code_text_contains_test); 139 tcase_add_test(tc, elm_code_text_contains_test);
180 tcase_add_test(tc, elm_code_text_strpos_test); 140 tcase_add_test(tc, elm_code_text_strpos_test);
181 tcase_add_test(tc, elm_code_text_newline_position_test); 141 tcase_add_test(tc, elm_code_text_newline_position_test);
182 tcase_add_test(tc, elm_code_text_leading_whitespace_test);
183 tcase_add_test(tc, elm_code_text_trailing_whitespace_test);
184 tcase_add_test(tc, elm_code_text_is_whitespace_test); 142 tcase_add_test(tc, elm_code_text_is_whitespace_test);
185} 143}
diff --git a/src/tests/elementary/elm_suite.c b/src/tests/elementary/elm_suite.c
index 0507325..146b261 100644
--- a/src/tests/elementary/elm_suite.c
+++ b/src/tests/elementary/elm_suite.c
@@ -72,15 +72,16 @@ static const Efl_Test_Case etc[] = {
72 { "elm_slideshow", elm_test_slideshow}, 72 { "elm_slideshow", elm_test_slideshow},
73 { "elm_spinner", elm_test_spinner}, 73 { "elm_spinner", elm_test_spinner},
74 { "elm_plug", elm_test_plug}, 74 { "elm_plug", elm_test_plug},
75 { "file_load", elm_code_file_test_load }, 75 { "elm_code_file_load", elm_code_file_test_load },
76 { "file_memory", elm_code_file_test_memory }, 76 { "elm_code_file_memory", elm_code_file_test_memory },
77 { "parse", elm_code_test_parse }, 77 { "elm_code_parse", elm_code_test_parse },
78 { "text", elm_code_test_text }, 78 { "elm_code_text", elm_code_test_text },
79 { "basic", elm_code_test_basic }, 79 { "elm_code_indent", elm_code_test_indent },
80 { "widget", elm_code_test_widget }, 80 { "elm_code_basic", elm_code_test_basic },
81 { "widget_text", elm_code_test_widget_text }, 81 { "elm_code_widget", elm_code_test_widget },
82 { "widget_selection", elm_code_test_widget_selection }, 82 { "elm_code_widget_text", elm_code_test_widget_text },
83 { "widget_undo", elm_code_test_widget_undo }, 83 { "elm_code_widget_selection", elm_code_test_widget_selection },
84 { "elm_code_widget_undo", elm_code_test_widget_undo },
84 { NULL, NULL } 85 { NULL, NULL }
85}; 86};
86 87
diff --git a/src/tests/elementary/elm_suite.h b/src/tests/elementary/elm_suite.h
index 076bb60..e161331 100644
--- a/src/tests/elementary/elm_suite.h
+++ b/src/tests/elementary/elm_suite.h
@@ -76,6 +76,7 @@ void elm_code_test_basic(TCase *tc);
76void elm_code_test_line(TCase *tc); 76void elm_code_test_line(TCase *tc);
77void elm_code_test_parse(TCase *tc); 77void elm_code_test_parse(TCase *tc);
78void elm_code_test_text(TCase *tc); 78void elm_code_test_text(TCase *tc);
79void elm_code_test_indent(TCase *tc);
79void elm_code_test_widget(TCase *tc); 80void elm_code_test_widget(TCase *tc);
80void elm_code_test_widget_text(TCase *tc); 81void elm_code_test_widget_text(TCase *tc);
81void elm_code_test_widget_selection(TCase *tc); 82void elm_code_test_widget_selection(TCase *tc);