Changeset 6ff651b for tests/check_set.c


Ignore:
Timestamp:
2019-11-19T12:51:39Z (3 months ago)
Author:
Dima <dgoldin+github@…>
Branches:
master
Children:
b504415
Parents:
bcd8f52
Message:

Fixing tests for libcheck 0.13.0

Since libcheck 0.13 it's mandatory to wrap the unit-test code
in a block. This updates the tests to comply with this.

This fix is backwards compatible with libcheck 0.12.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/check_set.c

    rbcd8f52 r6ff651b  
    88
    99START_TEST(test_set_add)
    10 void *data = "data";
    11 set_t *s = NULL, *t;
    12 t = set_add(&s, "name", "default", NULL, data);
    13 fail_unless(s == t);
    14 fail_unless(t->data == data);
    15 fail_unless(strcmp(t->def, "default") == 0);
     10{
     11    void *data = "data";
     12    set_t *s = NULL, *t;
     13    t = set_add(&s, "name", "default", NULL, data);
     14    fail_unless(s == t);
     15    fail_unless(t->data == data);
     16    fail_unless(strcmp(t->def, "default") == 0);
     17}
    1618END_TEST
    1719
    1820START_TEST(test_set_add_existing)
    19 void *data = "data";
    20 set_t *s = NULL, *t;
    21 t = set_add(&s, "name", "default", NULL, data);
    22 t = set_add(&s, "name", "newdefault", NULL, data);
    23 fail_unless(s == t);
    24 fail_unless(strcmp(t->def, "newdefault") == 0);
     21{
     22    void *data = "data";
     23    set_t *s = NULL, *t;
     24    t = set_add(&s, "name", "default", NULL, data);
     25    t = set_add(&s, "name", "newdefault", NULL, data);
     26    fail_unless(s == t);
     27    fail_unless(strcmp(t->def, "newdefault") == 0);
     28}
    2529END_TEST
    2630
    2731START_TEST(test_set_find_unknown)
    28 set_t * s = NULL;
    29 fail_unless(set_find(&s, "foo") == NULL);
     32{
     33    set_t * s = NULL;
     34    fail_unless(set_find(&s, "foo") == NULL);
     35}
    3036END_TEST
    3137
    3238START_TEST(test_set_find)
    33 void *data = "data";
    34 set_t *s = NULL, *t;
    35 t = set_add(&s, "name", "default", NULL, data);
    36 fail_unless(s == t);
    37 fail_unless(set_find(&s, "name") == t);
     39{
     40    void *data = "data";
     41    set_t *s = NULL, *t;
     42    t = set_add(&s, "name", "default", NULL, data);
     43    fail_unless(s == t);
     44    fail_unless(set_find(&s, "name") == t);
     45}
    3846END_TEST
    3947
    4048START_TEST(test_set_get_str_default)
    41 void *data = "data";
    42 set_t *s = NULL, *t;
    43 t = set_add(&s, "name", "default", NULL, data);
    44 fail_unless(s == t);
    45 fail_unless(strcmp(set_getstr(&s, "name"), "default") == 0);
     49{
     50    void *data = "data";
     51    set_t *s = NULL, *t;
     52    t = set_add(&s, "name", "default", NULL, data);
     53    fail_unless(s == t);
     54    fail_unless(strcmp(set_getstr(&s, "name"), "default") == 0);
     55}
    4656END_TEST
    4757
    4858START_TEST(test_set_get_bool_default)
    49 void *data = "data";
    50 set_t *s = NULL, *t;
    51 t = set_add(&s, "name", "true", NULL, data);
    52 fail_unless(s == t);
    53 fail_unless(set_getbool(&s, "name"));
     59{
     60    void *data = "data";
     61    set_t *s = NULL, *t;
     62    t = set_add(&s, "name", "true", NULL, data);
     63    fail_unless(s == t);
     64    fail_unless(set_getbool(&s, "name"));
     65}
    5466END_TEST
    5567
    5668START_TEST(test_set_get_bool_integer)
    57 void *data = "data";
    58 set_t *s = NULL, *t;
    59 t = set_add(&s, "name", "3", NULL, data);
    60 fail_unless(s == t);
    61 fail_unless(set_getbool(&s, "name") == 3);
     69{
     70    void *data = "data";
     71    set_t *s = NULL, *t;
     72    t = set_add(&s, "name", "3", NULL, data);
     73    fail_unless(s == t);
     74    fail_unless(set_getbool(&s, "name") == 3);
     75}
    6276END_TEST
    6377
    6478START_TEST(test_set_get_bool_unknown)
    65 set_t * s = NULL;
    66 fail_unless(set_getbool(&s, "name") == 0);
     79{
     80    set_t * s = NULL;
     81    fail_unless(set_getbool(&s, "name") == 0);
     82}
    6783END_TEST
    6884
    6985START_TEST(test_set_get_str_value)
    70 void *data = "data";
    71 set_t *s = NULL;
    72 set_add(&s, "name", "default", NULL, data);
    73 set_setstr(&s, "name", "foo");
    74 fail_unless(strcmp(set_getstr(&s, "name"), "foo") == 0);
     86{
     87    void *data = "data";
     88    set_t *s = NULL;
     89    set_add(&s, "name", "default", NULL, data);
     90    set_setstr(&s, "name", "foo");
     91    fail_unless(strcmp(set_getstr(&s, "name"), "foo") == 0);
     92}
    7593END_TEST
    7694
    7795START_TEST(test_set_get_str_unknown)
    78 set_t * s = NULL;
    79 fail_unless(set_getstr(&s, "name") == NULL);
     96{
     97    set_t * s = NULL;
     98    fail_unless(set_getstr(&s, "name") == NULL);
     99}
    80100END_TEST
    81101
    82102START_TEST(test_setint)
    83 void *data = "data";
    84 set_t *s = NULL;
    85 set_add(&s, "name", "10", NULL, data);
    86 set_setint(&s, "name", 3);
    87 fail_unless(set_getint(&s, "name") == 3);
     103{
     104    void *data = "data";
     105    set_t *s = NULL;
     106    set_add(&s, "name", "10", NULL, data);
     107    set_setint(&s, "name", 3);
     108    fail_unless(set_getint(&s, "name") == 3);
     109}
    88110END_TEST
    89111
    90112START_TEST(test_setstr)
    91 void *data = "data";
    92 set_t *s = NULL;
    93 set_add(&s, "name", "foo", NULL, data);
    94 set_setstr(&s, "name", "bloe");
    95 fail_unless(strcmp(set_getstr(&s, "name"), "bloe") == 0);
     113{
     114    void *data = "data";
     115    set_t *s = NULL;
     116    set_add(&s, "name", "foo", NULL, data);
     117    set_setstr(&s, "name", "bloe");
     118    fail_unless(strcmp(set_getstr(&s, "name"), "bloe") == 0);
     119}
    96120END_TEST
    97121
    98122START_TEST(test_set_get_int_unknown)
    99 set_t * s = NULL;
    100 fail_unless(set_getint(&s, "foo") == 0);
     123{
     124    set_t * s = NULL;
     125    fail_unless(set_getint(&s, "foo") == 0);
     126}
    101127END_TEST
    102128
Note: See TracChangeset for help on using the changeset viewer.