diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/test_endswap.def | 13 | ||||
-rw-r--r-- | src/test_endswap.tpl | 32 |
3 files changed, 49 insertions, 1 deletions
@@ -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 diff --git a/src/test_endswap.def b/src/test_endswap.def index c817322..3ca889a 100644 --- a/src/test_endswap.def +++ b/src/test_endswap.def @@ -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" ; + } ; diff --git a/src/test_endswap.tpl b/src/test_endswap.tpl index ad7cee1..939cf62 100644 --- a/src/test_endswap.tpl +++ b/src/test_endswap.tpl @@ -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 */ |