41,10 → 41,11 |
#include <malloc.h> |
#include <stdio.h> |
|
#include "int_map.h" |
#include "char_map.h" |
#include "generic_char_map.h" |
#include "measured_strings.h" |
#include "include/crc.h" |
#include "structures/int_map.h" |
#include "structures/char_map.h" |
#include "structures/generic_char_map.h" |
#include "structures/measured_strings.h" |
|
#include "self_test.h" |
|
52,6 → 53,7 |
printf( "\n\t%s", ( name )); \ |
if(( function_call ) != ( result )){ \ |
printf( "\tERROR" ); \ |
error = 1; \ |
}else{ \ |
printf( "\tOK" ); \ |
} \ |
82,6 → 84,7 |
#endif |
|
int self_test( void ){ |
int error = 0; |
int * x, * y, * z, * u, * v, * w; |
|
#if NET_SELF_TEST_MEASURED_STRINGS |
88,7 → 91,7 |
measured_string_ref string; |
|
printf( "\nMeasured strings test" ); |
string = measured_string_create_bulk( "I am a measured string!", -1 ); |
string = measured_string_create_bulk( "I am a measured string!", 0 ); |
printf( "\n%x, %s at %x of %d", string, string->value, string->value, string->length ); |
printf( "\nOK" ); |
#endif |
132,10 → 135,11 |
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL ); |
printf( "\nOK" ); |
|
if( error ) return EINVAL; |
|
#endif |
|
#if NET_SELF_TEST_INT_MAP |
|
int_map_t im; |
|
x = ( int * ) malloc( sizeof( int )); |
185,10 → 189,11 |
TEST( "count -1", int_map_count( & im ), -1 ); |
printf( "\nOK" ); |
|
if( error ) return EINVAL; |
|
#endif |
|
#if NET_SELF_TEST_GENERIC_FIELD |
|
int_field_t gf; |
|
x = ( int * ) malloc( sizeof( int )); |
235,10 → 240,11 |
TEST( "count -1", int_field_count( & gf ), -1 ); |
printf( "\nOK" ); |
|
if( error ) return EINVAL; |
|
#endif |
|
#if NET_SELF_TEST_GENERIC_CHAR_MAP |
|
int_char_map_t icm; |
|
x = ( int * ) malloc( sizeof( int )); |
277,8 → 283,40 |
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL ); |
printf( "\nOK" ); |
|
if( error ) return EINVAL; |
|
#endif |
|
#if NET_SELF_TEST_CRC |
uint32_t value; |
|
printf( "\nCRC computation test" ); |
value = ~ compute_crc32( ~ 0, "123456789", 8 * 9 ); |
TEST( "123456789", value, 0xCBF43926 ); |
printf( "\t=> %X", value ); |
value = ~ compute_crc32( ~ 0, "1", 8 ); |
TEST( "1", value, 0x83DCEFB7 ); |
printf( "\t=> %X", value ); |
value = ~ compute_crc32( ~ 0, "12", 8 * 2 ); |
TEST( "12", value, 0x4F5344CD ); |
printf( "\t=> %X", value ); |
value = ~ compute_crc32( ~ 0, "123", 8 * 3 ); |
TEST( "123", value, 0x884863D2 ); |
printf( "\t=> %X", value ); |
value = ~ compute_crc32( ~ 0, "1234", 8 * 4 ); |
TEST( "1234", value, 0x9BE3E0A3 ); |
printf( "\t=> %X", value ); |
value = ~ compute_crc32( ~ 0, "12345678", 8 * 8 ); |
TEST( "12345678", value, 0x9AE0DAAF ); |
printf( "\t=> %X", value ); |
value = ~ compute_crc32( ~ 0, "ahoj pane", 8 * 9 ); |
TEST( "ahoj pane", value, 0x5FC3D706 ); |
printf( "\t=> %X", value ); |
|
if( error ) return EINVAL; |
|
#endif |
|
return EOK; |
} |
|