aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/tests/eina_test_file.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/eina/src/tests/eina_test_file.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/libraries/eina/src/tests/eina_test_file.c b/libraries/eina/src/tests/eina_test_file.c
index 55e9976..a3ba998 100644
--- a/libraries/eina/src/tests/eina_test_file.c
+++ b/libraries/eina/src/tests/eina_test_file.c
@@ -28,6 +28,44 @@
28#include "Eina.h" 28#include "Eina.h"
29#include "eina_safety_checks.h" 29#include "eina_safety_checks.h"
30 30
31#ifdef EINA_SAFETY_CHECKS
32struct log_ctx {
33 const char *msg;
34 const char *fnc;
35 Eina_Bool did;
36};
37
38/* tests should not output on success, just uncomment this for debugging */
39//#define SHOW_LOG 1
40
41static void
42_eina_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args __UNUSED__)
43{
44 struct log_ctx *ctx = data;
45 va_list cp_args;
46 const char *str;
47
48 va_copy(cp_args, args);
49 str = va_arg(cp_args, const char *);
50 va_end(cp_args);
51
52 ck_assert_int_eq(level, EINA_LOG_LEVEL_ERR);
53 ck_assert_str_eq(fmt, "%s");
54 ck_assert_str_eq(ctx->msg, str);
55 ck_assert_str_eq(ctx->fnc, fnc);
56 ctx->did = EINA_TRUE;
57
58#ifdef SHOW_LOG
59 eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
60#else
61 (void)d;
62 (void)file;
63 (void)line;
64#endif
65}
66#endif
67
68
31START_TEST(eina_file_split_simple) 69START_TEST(eina_file_split_simple)
32{ 70{
33 Eina_Array *ea; 71 Eina_Array *ea;
@@ -35,10 +73,26 @@ START_TEST(eina_file_split_simple)
35 eina_init(); 73 eina_init();
36 74
37#ifdef EINA_SAFETY_CHECKS 75#ifdef EINA_SAFETY_CHECKS
76#ifdef SHOW_LOG
38 fprintf(stderr, "you should have a safety check failure below:\n"); 77 fprintf(stderr, "you should have a safety check failure below:\n");
78#endif
79 struct log_ctx ctx;
80
81#define TEST_MAGIC_SAFETY(fn, _msg) \
82 ctx.msg = _msg; \
83 ctx.fnc = fn; \
84 ctx.did = EINA_FALSE
85
86 eina_log_print_cb_set(_eina_test_safety_print_cb, &ctx);
87
88 TEST_MAGIC_SAFETY("eina_file_split", "safety check failed: path == NULL");
39 ea = eina_file_split(NULL); 89 ea = eina_file_split(NULL);
40 fail_if(ea); 90 fail_if(ea);
41 fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED); 91 fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
92 fail_unless(ctx.did);
93
94 eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
95#undef TEST_MAGIC_SAFETY
42#endif 96#endif
43 97
44#ifdef _WIN32 98#ifdef _WIN32