test/main.c

changeset 33
9c219a62070d
parent 31
91ac86557290
child 35
fdabd1240b69
     1.1 --- a/test/main.c	Thu May 31 09:18:26 2012 +0200
     1.2 +++ b/test/main.c	Thu May 31 12:51:22 2012 +0200
     1.3 @@ -51,25 +51,57 @@
     1.4      return cpy;
     1.5  }
     1.6  
     1.7 -UCX_TEST_BEGIN(testTestSuitePositive) {
     1.8 +UCX_TEST_IMPLEMENT(testTestSuitePositive) {
     1.9 +    UCX_TEST_BEGIN
    1.10      UCX_TEST_ASSERT(2*2 == 4, "the test framework fails")
    1.11      UCX_TEST_END
    1.12  }
    1.13  
    1.14 -UCX_TEST_BEGIN(testTestSuiteNegative) {
    1.15 +UCX_TEST_IMPLEMENT(testTestSuiteNegative) {
    1.16 +    UCX_TEST_BEGIN
    1.17      UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works")
    1.18      UCX_TEST_END
    1.19  }
    1.20  
    1.21 +UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess,field) {
    1.22 +    int* i = (int*) field;
    1.23 +    *i += 2;
    1.24 +    UCX_TEST_ASSERT(*i==4, "the test framework fails");
    1.25 +}
    1.26 +
    1.27 +UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure,field) {
    1.28 +    int* i = (int*) field;
    1.29 +    *i += 2;
    1.30 +    UCX_TEST_ASSERT(*i==4, "the test framework works");
    1.31 +}
    1.32 +
    1.33 +UCX_TEST_IMPLEMENT(testTestSuiteRoutinePositive) {
    1.34 +    int i = 2;
    1.35 +    UCX_TEST_BEGIN
    1.36 +    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i);
    1.37 +    UCX_TEST_ASSERT(i==4, "the test framework fails");
    1.38 +    UCX_TEST_END
    1.39 +}
    1.40 +
    1.41 +UCX_TEST_IMPLEMENT(testTestSuiteRoutineNegative) {
    1.42 +    int i = 0;
    1.43 +    UCX_TEST_BEGIN
    1.44 +    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i);
    1.45 +    UCX_TEST_ASSERT(1, "the test framework fails");
    1.46 +    UCX_TEST_END
    1.47 +}
    1.48 +
    1.49  int main(int argc, char **argv) {
    1.50      printf("UCX Tests\n---------\n");
    1.51  
    1.52 -    printf("\nUcxTestSuite tests (1 failure is intended!)\n");
    1.53 +    printf("\nUcxTestSuite tests (2 failures are intended!)\n");
    1.54      UcxTestSuite* suite = ucx_test_suite_new();
    1.55      ucx_test_register(suite, testTestSuitePositive);
    1.56      ucx_test_register(suite, testTestSuiteNegative);
    1.57 +    ucx_test_register(suite, testTestSuiteRoutinePositive);
    1.58 +    ucx_test_register(suite, testTestSuiteRoutineNegative);
    1.59      ucx_test_run(suite, stdout);
    1.60 -    if (suite->failure == 1 && suite->success == 1) {
    1.61 +    if (suite->failure == 2 && suite->success == 2) {
    1.62          ucx_test_suite_free(suite);
    1.63  
    1.64          printf("\nLibrary function tests\n");
    1.65 @@ -112,6 +144,7 @@
    1.66          ucx_test_register(suite, test_ucx_map_put);
    1.67          ucx_test_register(suite, test_ucx_map_get);
    1.68          ucx_test_register(suite, test_ucx_map_iterator);
    1.69 +        ucx_test_register(suite, test_ucx_map_iterator_chain);
    1.70          
    1.71          ucx_test_run(suite, stdout);
    1.72          ucx_test_suite_free(suite);

mercurial