aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2017-10-13 14:36:31 +0900
committerAmitesh Singh <amitesh.sh@samsung.com>2017-10-13 16:04:24 +0900
commit2cf24eb30428fd56e32b1633ab3d795a3fbea5a3 (patch)
treed6e36177a4fe073338e24e47b19ddb12e7a85867 /src/tests
parentefl_animation: Fix shadowing local variable warning (diff)
downloadefl-2cf24eb30428fd56e32b1633ab3d795a3fbea5a3.tar.gz
eina: strbuf - Add strftime related functions
eina_strbuf_append_strftime() eina_strbuf_insert_strftime() eina_strbuf_prepend_strftime() - macro We need these functions for implementing generic format function interface especially for calander. Ref https://phab.enlightenment.org/T6204
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/eina/eina_test_strbuf.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/eina/eina_test_strbuf.c b/src/tests/eina/eina_test_strbuf.c
index 0511d96011..4add7a188e 100644
--- a/src/tests/eina/eina_test_strbuf.c
+++ b/src/tests/eina/eina_test_strbuf.c
@@ -660,6 +660,36 @@ START_TEST(strbuf_release_test)
}
END_TEST
+START_TEST(strbuf_strftime_test)
+{
+ Eina_Strbuf *buf;
+ time_t curr_time;
+ struct tm *info;
+ char cbuf[32];
+ const char *str;
+
+ curr_time = time(NULL);
+ info = localtime(&curr_time);
+
+ strftime(cbuf, 32, "%I:%M%p", info);
+
+ buf = eina_strbuf_new();
+ eina_strbuf_append_strftime(buf, "%I:%M%p", info);
+ str = eina_strbuf_string_get(buf);
+ fail_if(str == NULL || strcmp(str, cbuf) != 0);
+ eina_strbuf_reset(buf);
+
+ buf = eina_strbuf_new();
+ eina_strbuf_append(buf, "Hours: Minutes");
+ eina_strbuf_prepend_strftime(buf, "%I ", info);
+ eina_strbuf_insert_strftime(buf, "%M ", info, 10);
+ strftime(cbuf, 32, "%I Hours: %M Minutes", info);
+ str = eina_strbuf_string_get(buf);
+ fail_if(str == NULL || strcmp(str, cbuf) != 0);
+
+ eina_strbuf_free(buf);
+}
+
void
eina_test_strbuf(TCase *tc)
{
@@ -677,4 +707,5 @@ eina_test_strbuf(TCase *tc)
tcase_add_test(tc, strbuf_substr_get);
tcase_add_test(tc, strbuf_prepend_print);
tcase_add_test(tc, strbuf_release_test);
+ tcase_add_test(tc, strbuf_strftime_test);
}