fprintf(stderr, "\n");
}
-int
+bool
cct_check_int_eq(const char *file, int line, const char *expression,
int64_t expected, int64_t actual)
{
if (expected == actual) {
cct_check_passed(file, line, expression);
- return 1;
+ return true;
} else {
#ifdef HAVE_LONG_LONG
char *exp_str = format("%lld", (long long)expected);
cct_check_failed(file, line, expression, exp_str, act_str);
free(exp_str);
free(act_str);
- return 0;
+ return false;
}
}
-int
+bool
cct_check_str_eq(const char *file, int line, const char *expression,
- const char *expected, const char *actual, int free1,
- int free2)
+ const char *expected, const char *actual, bool free1,
+ bool free2)
{
- int result;
+ bool result;
if (expected && actual && str_eq(actual, expected)) {
cct_check_passed(file, line, expression);
- result = 1;
+ result = true;
} else {
char *exp_str = expected ? format("\"%s\"", expected) : x_strdup("(null)");
char *act_str = actual ? format("\"%s\"", actual) : x_strdup("(null)");
cct_check_failed(file, line, expression, exp_str, act_str);
free(exp_str);
free(act_str);
- result = 0;
+ result = false;
}
if (free1) {
return result;
}
-int
+bool
cct_check_args_eq(const char *file, int line, const char *expression,
struct args *expected, struct args *actual,
- int free1, int free2)
+ bool free1, bool free2)
{
- int result;
+ bool result;
if (expected && actual && args_equal(actual, expected)) {
cct_check_passed(file, line, expression);
- result = 1;
+ result = true;
} else {
char *exp_str = expected ? args_to_string(expected) : x_strdup("(null)");
char *act_str = actual ? args_to_string(actual) : x_strdup("(null)");
cct_check_failed(file, line, expression, exp_str, act_str);
free(exp_str);
free(act_str);
- result = 0;
+ result = false;
}
if (free1) {
/*
- * Copyright (C) 2010-2011 Joel Rosdahl
+ * Copyright (C) 2010-2012 Joel Rosdahl
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
cct_suite_end(); \
return _test_counter; \
} \
- } while (0)
+ } while (false)
#define CHECK(assertion) \
CHECKM(assertion, NULL)
cct_suite_end(); \
return _test_counter; \
} \
- } while (0)
+ } while (false)
/*****************************************************************************/
cct_suite_end(); \
return _test_counter; \
} \
- } while (0)
+ } while (false)
/*****************************************************************************/
#define CHECK_STR_EQ(expected, actual) \
- CHECK_POINTER_EQ_BASE(str, expected, actual, 0, 0)
+ CHECK_POINTER_EQ_BASE(str, expected, actual, false, false)
#define CHECK_STR_EQ_FREE1(expected, actual) \
- CHECK_POINTER_EQ_BASE(str, expected, actual, 1, 0)
+ CHECK_POINTER_EQ_BASE(str, expected, actual, true, false)
#define CHECK_STR_EQ_FREE2(expected, actual) \
- CHECK_POINTER_EQ_BASE(str, expected, actual, 0, 1)
+ CHECK_POINTER_EQ_BASE(str, expected, actual, false, true)
#define CHECK_STR_EQ_FREE12(expected, actual) \
- CHECK_POINTER_EQ_BASE(str, expected, actual, 1, 1)
+ CHECK_POINTER_EQ_BASE(str, expected, actual, true, true)
/*****************************************************************************/
#define CHECK_ARGS_EQ(expected, actual) \
- CHECK_POINTER_EQ_BASE(args, expected, actual, 0, 0)
+ CHECK_POINTER_EQ_BASE(args, expected, actual, false, false)
#define CHECK_ARGS_EQ_FREE1(expected, actual) \
- CHECK_POINTER_EQ_BASE(args, expected, actual, 1, 0)
+ CHECK_POINTER_EQ_BASE(args, expected, actual, true, false)
#define CHECK_ARGS_EQ_FREE2(expected, actual) \
- CHECK_POINTER_EQ_BASE(args, expected, actual, 0, 1)
+ CHECK_POINTER_EQ_BASE(args, expected, actual, false, true)
#define CHECK_ARGS_EQ_FREE12(expected, actual) \
- CHECK_POINTER_EQ_BASE(args, expected, actual, 1, 1)
+ CHECK_POINTER_EQ_BASE(args, expected, actual, true, true)
/*****************************************************************************/
void cct_check_passed(const char *file, int line, const char *assertion);
void cct_check_failed(const char *file, int line, const char *assertion,
const char *expected, const char *actual);
-int cct_check_int_eq(const char *file, int line, const char *expression,
- int64_t expected, int64_t actual);
-int cct_check_str_eq(const char *file, int line, const char *expression,
- const char *expected, const char *actual, int free1,
- int free2);
-int cct_check_args_eq(const char *file, int line, const char *expression,
- struct args *expected, struct args *actual,
- int free1, int free2);
+bool cct_check_int_eq(const char *file, int line, const char *expression,
+ int64_t expected, int64_t actual);
+bool cct_check_str_eq(const char *file, int line, const char *expression,
+ const char *expected, const char *actual, bool free1,
+ bool free2);
+bool cct_check_args_eq(const char *file, int line, const char *expression,
+ struct args *expected, struct args *actual,
+ bool free1, bool free2);
void cct_chdir(const char *path);
void cct_wipe(const char *path);
void cct_create_fresh_dir(const char *path);