src/ : Add tests for psf_put_be32() and psf_put_be64().

This commit is contained in:
Erik de Castro Lopo 2013-02-13 18:21:55 +11:00
parent c3c39ed677
commit 6ced621a66
3 changed files with 49 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2013-02-13 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/test_endswap.def src/test_endswap.tpl
Add tests for psf_put_be32() and psf_put_be64().
2013-02-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sfendian.h

View File

@ -18,3 +18,16 @@ int_type = {
format = FMT_INT64 ;
} ;
int_size = {
name = 32 ;
typename = int32_t ;
value = 0x30313233 ;
strval = "0123" ;
} ;
int_size = {
name = 64 ;
typename = int64_t ;
value = 0x3031323334353637 ;
strval = "01234567" ;
} ;

View File

@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2002-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@ -105,6 +105,30 @@ test_endswap_[+ (get "name") +] (void)
[+ ENDFOR int_type
+]
[+ FOR int_size +]
static void
test_psf_put_be[+ (get "name") +] (void)
{ const char *test = "[+ (get "strval") +]" ;
uint8_t array [20] ;
int k ;
printf (" %-40s : ", __func__) ;
fflush (stdout) ;
for (k = 0 ; k < 6 ; k++)
{ memset (array, 0, sizeof (array)) ;
psf_put_be[+ (get "name") +] (array, k, [+ (get "value") +]) ;
if (memcmp (array + k, test, sizeof ([+ (get "typename") +])) != 0)
{ printf ("Failed at %d\n", k) ;
exit (1) ;
} ;
} ;
puts ("ok") ;
} /* test_psf_put_be[+ (get "name") +] */
[+ ENDFOR int_size
+]
void
test_endswap (void)
@ -113,5 +137,11 @@ test_endswap (void)
+] test_endswap_[+ (get "name") +] () ;
[+ ENDFOR int_type
+]
[+ FOR int_size
+] test_psf_put_be[+ (get "name") +] () ;
[+ ENDFOR int_endsize
+]
} /* test_endswap */