summaryrefslogtreecommitdiff
path: root/common/tests/test-constants.c
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-04-05 23:52:39 +0200
committerStef Walter <stefw@gnome.org>2013-05-21 11:31:09 +0200
commitdcabaf1d56d410ba7ddb3dfbab9011bbbea5e6bc (patch)
treec49effa4a0696dc00fb591d95dc59e8579a8d030 /common/tests/test-constants.c
parent7fd6d89d92b6f1b543bf2aa4b2e578201dad7147 (diff)
Our own unit testing framework
* Support the TAP protocol * Much cleaner without having to carry around state * First class support for setup/teardown * Port the common tests * Wait on porting other tests until we've merged outstanding code
Diffstat (limited to 'common/tests/test-constants.c')
-rw-r--r--common/tests/test-constants.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/common/tests/test-constants.c b/common/tests/test-constants.c
index 4c2f3eb..76c44d2 100644
--- a/common/tests/test-constants.c
+++ b/common/tests/test-constants.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include <stdlib.h>
#include <stdio.h>
@@ -44,7 +44,7 @@
#include "debug.h"
static void
-test_constants (CuTest *tc)
+test_constants (void)
{
const p11_constant *constant;
p11_dict *nicks, *names;
@@ -72,29 +72,27 @@ test_constants (CuTest *tc)
for (j = 0; constants[j] != NULL; j++) {
constant = constants[j];
for (i = 1; constant[i].value != CKA_INVALID; i++) {
- if (constant[i].value < constant[i - 1].value) {
- CuFail_Line (tc, __FILE__, __LINE__,
- "attr constant out of order", constant[i].name);
- }
+ if (constant[i].value < constant[i - 1].value)
+ assert_fail ("attr constant out of order", constant[i].name);
}
for (i = 0; constant[i].value != CKA_INVALID; i++) {
- CuAssertPtrNotNull (tc, constant[i].name);
+ assert_ptr_not_null (constant[i].name);
if (constant[i].nick) {
- CuAssertStrEquals (tc, constant[i].nick,
- p11_constant_nick (constant, constant[i].value));
+ assert_str_eq (constant[i].nick,
+ p11_constant_nick (constant, constant[i].value));
}
- CuAssertStrEquals (tc, constant[i].name,
- p11_constant_name (constant, constant[i].value));
+ assert_str_eq (constant[i].name,
+ p11_constant_name (constant, constant[i].value));
if (constant[i].nick) {
check = p11_constant_resolve (nicks, constant[i].nick);
- CuAssertIntEquals (tc, constant[i].value, check);
+ assert_num_eq (constant[i].value, check);
}
check = p11_constant_resolve (names, constant[i].name);
- CuAssertIntEquals (tc, constant[i].value, check);
+ assert_num_eq (constant[i].value, check);
}
}
@@ -103,23 +101,10 @@ test_constants (CuTest *tc)
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
- p11_debug_init ();
- SUITE_ADD_TEST (suite, test_constants);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
+ p11_test (test_constants, "/constants/all");
- return ret;
+ return p11_test_run (argc, argv);
}