Subversion Repositories HelenOS

Rev

Rev 3666 | Rev 3912 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3666 Rev 3846
Line 46... Line 46...
46
#include "generic_char_map.h"
46
#include "generic_char_map.h"
47
#include "measured_strings.h"
47
#include "measured_strings.h"
48
 
48
 
49
#include "self_test.h"
49
#include "self_test.h"
50
 
50
 
51
#define TEST( name, function_call, result );    {           \
51
#define TEST( name, function_call, result );    {   \
52
    printf( "\n\t%s", ( name ));                    \
52
    printf( "\n\t%s", ( name ));                    \
53
    if(( function_call ) != ( result )){                \
53
    if(( function_call ) != ( result )){            \
54
        printf( "\tERROR" );                    \
54
        printf( "\tERROR" );                        \
55
    }else{                              \
55
    }else{                                          \
56
        printf( "\tOK" );                   \
56
        printf( "\tOK" );                           \
57
    }                               \
57
    }                                               \
58
}
58
}
59
 
59
 
60
#if NET_SELF_TEST_INT_MAP
60
#if NET_SELF_TEST_INT_MAP
61
 
61
 
62
    INT_MAP_DECLARE( int_map, int );
62
    INT_MAP_DECLARE( int_map, int );
Line 95... Line 95...
95
 
95
 
96
#if NET_SELF_TEST_CHAR_MAP
96
#if NET_SELF_TEST_CHAR_MAP
97
    char_map_t  cm;
97
    char_map_t  cm;
98
 
98
 
99
    printf( "\nChar map test" );
99
    printf( "\nChar map test" );
100
    TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 3 ), EINVAL );
100
    TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL );
101
    TEST( "initialize", char_map_initialize( & cm ), EOK );
101
    TEST( "initialize", char_map_initialize( & cm ), EOK );
102
    TEST( "get_value", char_map_get_value( & cm ), CHAR_MAP_NULL );
102
    TEST( "get_value", char_map_get_value( & cm ), CHAR_MAP_NULL );
103
    TEST( "exclude bla null", char_map_exclude( & cm, "bla" ), CHAR_MAP_NULL );
103
    TEST( "exclude bla null", char_map_exclude( & cm, "bla", 0 ), CHAR_MAP_NULL );
104
    TEST( "find bla null", char_map_find( & cm, "bla" ), CHAR_MAP_NULL );
104
    TEST( "find bla null", char_map_find( & cm, "bla", 0 ), CHAR_MAP_NULL );
105
    TEST( "add bla 1 eok", char_map_add( & cm, "bla", 1 ), EOK );
105
    TEST( "add bla 1 eok", char_map_add( & cm, "bla", 0, 1 ), EOK );
106
    TEST( "find bla 1", char_map_find( & cm, "bla" ), 1 );
106
    TEST( "find bla 1", char_map_find( & cm, "bla", 0 ), 1 );
107
    TEST( "add bla 10 eexists", char_map_add( & cm, "bla", 10 ), EEXISTS );
107
    TEST( "add bla 10 eexists", char_map_add( & cm, "bla", 0, 10 ), EEXISTS );
108
    TEST( "update bla 2 eok", char_map_update( & cm, "bla", 2 ), EOK );
108
    TEST( "update bla 2 eok", char_map_update( & cm, "bla", 0, 2 ), EOK );
109
    TEST( "find bla 2", char_map_find( & cm, "bla" ), 2 );
109
    TEST( "find bla 2", char_map_find( & cm, "bla", 0 ), 2 );
110
    TEST( "update ucho 2 eok", char_map_update( & cm, "ucho", 2 ), EOK );
110
    TEST( "update ucho 2 eok", char_map_update( & cm, "ucho", 0, 2 ), EOK );
111
    TEST( "exclude bla 2", char_map_exclude( & cm, "bla" ), 2 );
111
    TEST( "exclude bla 2", char_map_exclude( & cm, "bla", 0 ), 2 );
112
    TEST( "exclude bla null", char_map_exclude( & cm, "bla" ), CHAR_MAP_NULL );
112
    TEST( "exclude bla null", char_map_exclude( & cm, "bla", 0 ), CHAR_MAP_NULL );
113
    TEST( "find ucho 2", char_map_find( & cm, "ucho" ), 2 );
113
    TEST( "find ucho 2", char_map_find( & cm, "ucho", 0 ), 2 );
114
    TEST( "update ucho 3 eok", char_map_update( & cm, "ucho", 3 ), EOK );
114
    TEST( "update ucho 3 eok", char_map_update( & cm, "ucho", 0, 3 ), EOK );
115
    TEST( "find ucho 3", char_map_find( & cm, "ucho" ), 3 );
115
    TEST( "find ucho 3", char_map_find( & cm, "ucho", 0 ), 3 );
116
    TEST( "add blabla 5 eok", char_map_add( & cm, "blabla", 5 ), EOK );
116
    TEST( "add blabla 5 eok", char_map_add( & cm, "blabla", 0, 5 ), EOK );
117
    TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 );
117
    TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 );
118
    TEST( "add bla 6 eok", char_map_add( & cm, "bla", 6 ), EOK );
118
    TEST( "add bla 6 eok", char_map_add( & cm, "bla", 0, 6 ), EOK );
119
    TEST( "find bla 6", char_map_find( & cm, "bla" ), 6 );
119
    TEST( "find bla 6", char_map_find( & cm, "bla", 0 ), 6 );
120
    TEST( "exclude bla 6", char_map_exclude( & cm, "bla" ), 6 );
120
    TEST( "exclude bla 6", char_map_exclude( & cm, "bla", 0 ), 6 );
121
    TEST( "find bla null", char_map_find( & cm, "bla" ), CHAR_MAP_NULL );
121
    TEST( "find bla null", char_map_find( & cm, "bla", 0 ), CHAR_MAP_NULL );
122
    TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 );
122
    TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 );
123
    TEST( "add auto 7 eok", char_map_add( & cm, "auto", 7 ), EOK );
123
    TEST( "add auto 7 eok", char_map_add( & cm, "auto", 0, 7 ), EOK );
124
    TEST( "find auto 7", char_map_find( & cm, "auto" ), 7 );
124
    TEST( "find auto 7", char_map_find( & cm, "auto", 0 ), 7 );
125
    TEST( "add kara 8 eok", char_map_add( & cm, "kara", 8 ), EOK );
125
    TEST( "add kara 8 eok", char_map_add( & cm, "kara", 0, 8 ), EOK );
126
    TEST( "find kara 8", char_map_find( & cm, "kara" ), 8 );
126
    TEST( "find kara 8", char_map_find( & cm, "kara", 0 ), 8 );
127
    TEST( "add nic 9 eok", char_map_add( & cm, "nic", 9 ), EOK );
127
    TEST( "add nic 9 eok", char_map_add( & cm, "nic", 0, 9 ), EOK );
128
    TEST( "find nic 9", char_map_find( & cm, "nic" ), 9 );
128
    TEST( "find nic 9", char_map_find( & cm, "nic", 0 ), 9 );
129
    TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 );
129
    TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 );
130
    printf( "\n\tdestroy" );
130
    printf( "\n\tdestroy" );
131
    char_map_destroy( & cm );
131
    char_map_destroy( & cm );
132
    TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 3 ), EINVAL );
132
    TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL );
133
    printf( "\nOK" );
133
    printf( "\nOK" );
134
 
134
 
135
#endif
135
#endif
136
 
136
 
137
#if NET_SELF_TEST_INT_MAP
137
#if NET_SELF_TEST_INT_MAP
Line 248... Line 248...
248
    v = ( int * ) malloc( sizeof( int ));
248
    v = ( int * ) malloc( sizeof( int ));
249
    w = ( int * ) malloc( sizeof( int ));
249
    w = ( int * ) malloc( sizeof( int ));
250
 
250
 
251
    icm.magic = 0;
251
    icm.magic = 0;
252
    printf( "\nGeneric char map test" );
252
    printf( "\nGeneric char map test" );
253
    TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", z ), EINVAL );
253
    TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL );
254
    TEST( "initialize", int_char_map_initialize( & icm ), EOK );
254
    TEST( "initialize", int_char_map_initialize( & icm ), EOK );
255
    printf( "\n\texclude bla null" );
255
    printf( "\n\texclude bla null" );
256
    int_char_map_exclude( & icm, "bla" );
256
    int_char_map_exclude( & icm, "bla", 0 );
257
    TEST( "find bla null", int_char_map_find( & icm, "bla" ), NULL );
257
    TEST( "find bla null", int_char_map_find( & icm, "bla", 0 ), NULL );
258
    TEST( "add bla x eok", int_char_map_add( & icm, "bla", x ), EOK );
258
    TEST( "add bla x eok", int_char_map_add( & icm, "bla", 0, x ), EOK );
259
    TEST( "find bla x", int_char_map_find( & icm, "bla" ), x );
259
    TEST( "find bla x", int_char_map_find( & icm, "bla", 0 ), x );
260
    TEST( "add bla y eexists", int_char_map_add( & icm, "bla", y ), EEXISTS );
260
    TEST( "add bla y eexists", int_char_map_add( & icm, "bla", 0, y ), EEXISTS );
261
    printf( "\n\texclude bla y" );
261
    printf( "\n\texclude bla y" );
262
    int_char_map_exclude( & icm, "bla" );
262
    int_char_map_exclude( & icm, "bla", 0 );
263
    printf( "\n\texclude bla null" );
263
    printf( "\n\texclude bla null" );
264
    int_char_map_exclude( & icm, "bla" );
264
    int_char_map_exclude( & icm, "bla", 0 );
265
    TEST( "add blabla v eok", int_char_map_add( & icm, "blabla", v ), EOK );
265
    TEST( "add blabla v eok", int_char_map_add( & icm, "blabla", 0, v ), EOK );
266
    TEST( "find blabla v", int_char_map_find( & icm, "blabla" ), v );
266
    TEST( "find blabla v", int_char_map_find( & icm, "blabla", 0 ), v );
267
    TEST( "add bla w eok", int_char_map_add( & icm, "bla", w ), EOK );
267
    TEST( "add bla w eok", int_char_map_add( & icm, "bla", 0, w ), EOK );
268
    TEST( "find bla w", int_char_map_find( & icm, "bla" ), w );
268
    TEST( "find bla w", int_char_map_find( & icm, "bla", 0 ), w );
269
    printf( "\n\texclude bla" );
269
    printf( "\n\texclude bla" );
270
    int_char_map_exclude( & icm, "bla" );
270
    int_char_map_exclude( & icm, "bla", 0 );
271
    TEST( "find bla null", int_char_map_find( & icm, "bla" ), NULL );
271
    TEST( "find bla null", int_char_map_find( & icm, "bla", 0 ), NULL );
272
    TEST( "find blabla v", int_char_map_find( & icm, "blabla" ), v );
272
    TEST( "find blabla v", int_char_map_find( & icm, "blabla", 0 ), v );
273
    TEST( "add auto u eok", int_char_map_add( & icm, "auto", u ), EOK );
273
    TEST( "add auto u eok", int_char_map_add( & icm, "auto", 0, u ), EOK );
274
    TEST( "find auto u", int_char_map_find( & icm, "auto" ), u );
274
    TEST( "find auto u", int_char_map_find( & icm, "auto", 0 ), u );
275
    printf( "\n\tdestroy" );
275
    printf( "\n\tdestroy" );
276
    int_char_map_destroy( & icm );
276
    int_char_map_destroy( & icm );
277
    TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", z ), EINVAL );
277
    TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL );
278
    printf( "\nOK" );
278
    printf( "\nOK" );
279
 
279
 
280
#endif
280
#endif
281
 
281
 
282
    return EOK;
282
    return EOK;