test/main.c

changeset 88
18823857ce79
parent 76
655020a30e77
child 89
47f7fdbddb62
     1.1 --- a/test/main.c	Mon Feb 25 16:26:50 2013 +0100
     1.2 +++ b/test/main.c	Wed Feb 27 09:41:17 2013 +0100
     1.3 @@ -65,15 +65,23 @@
     1.4      UCX_TEST_END
     1.5  }
     1.6  
     1.7 -UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess,field) {
     1.8 -    int* i = (int*) field;
     1.9 +UCX_TEST_SUBROUTINE(testTestSuiteRoutineRoutine, float f) {
    1.10 +    UCX_TEST_ASSERT(f == 3.14f, "calling routine in a routine fails");
    1.11 +}
    1.12 +
    1.13 +UCX_TEST_SUBROUTINE(testTestSuiteRoutine2Param, int i, float f) {
    1.14 +    UCX_TEST_ASSERT(i == 42, "two parameter routine fails");
    1.15 +    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineRoutine, f);
    1.16 +}
    1.17 +
    1.18 +UCX_TEST_SUBROUTINE(testTestSuiteRoutineSuccess, int* i) {
    1.19      *i += 2;
    1.20      UCX_TEST_ASSERT(*i==4, "the test framework fails");
    1.21  }
    1.22  
    1.23 -UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure,field) {
    1.24 -    int* i = (int*) field;
    1.25 +UCX_TEST_SUBROUTINE(testTestSuiteRoutineFailure, int* i) {
    1.26      *i += 2;
    1.27 +    // Next test shall fail!
    1.28      UCX_TEST_ASSERT(*i==4, "the test framework works");
    1.29  }
    1.30  
    1.31 @@ -93,6 +101,12 @@
    1.32      UCX_TEST_END
    1.33  }
    1.34  
    1.35 +UCX_TEST_IMPLEMENT(testTestSuiteRoutineMultiparam) {
    1.36 +    UCX_TEST_BEGIN
    1.37 +    UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f);
    1.38 +    UCX_TEST_END
    1.39 +}
    1.40 +
    1.41  int main(int argc, char **argv) {
    1.42      printf("UCX Tests\n---------\n");
    1.43  
    1.44 @@ -102,8 +116,9 @@
    1.45      ucx_test_register(suite, testTestSuiteNegative);
    1.46      ucx_test_register(suite, testTestSuiteRoutinePositive);
    1.47      ucx_test_register(suite, testTestSuiteRoutineNegative);
    1.48 +    ucx_test_register(suite, testTestSuiteRoutineMultiparam);
    1.49      ucx_test_run(suite, stdout);
    1.50 -    if (suite->failure == 2 && suite->success == 2) {
    1.51 +    if (suite->failure == 2 && suite->success == 3) {
    1.52          ucx_test_suite_free(suite);
    1.53  
    1.54          printf("\nLibrary function tests\n");

mercurial