forked from Imagelibrary/rtems
2011-07-29 Pawel Zagorski <pzagor@agh.edu.pl>
PR 1865/tests * stringto01/Makefile.am, stringto01/init.c, stringto01/stringto01.doc, stringto01/stringto01.scn, stringto01/stringto_test_template.h: Improve coverage of string conversion routines.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2011-07-29 Pawel Zagorski <pzagor@agh.edu.pl>
|
||||
|
||||
PR 1865/tests
|
||||
* stringto01/Makefile.am, stringto01/init.c, stringto01/stringto01.doc,
|
||||
stringto01/stringto01.scn, stringto01/stringto_test_template.h:
|
||||
Improve coverage of string conversion routines.
|
||||
|
||||
2011-07-29 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* POSIX/iconv.c, POSIX/iconv_open.c, POSIX/iconv_close.c: New.
|
||||
|
||||
@@ -14,7 +14,6 @@ include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
stringto01_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
#define TEST_STRING_TO_NAME test_rtems_string_to_unsigned_char
|
||||
#define STRING_TO_NAME_METHOD rtems_string_to_unsigned_char
|
||||
#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_char"
|
||||
/* #define TEST_TOO_LARGE_STRING "987654321123456789123456789" */
|
||||
#define TEST_TOO_LARGE_STRING "987654321123456789123456789"
|
||||
#define TEST_TOO_LARGE_FOR_UCHAR "256"
|
||||
#define STRING_TO_INTEGER
|
||||
#include "stringto_test_template.h"
|
||||
|
||||
@@ -57,6 +58,7 @@
|
||||
#define STRING_TO_NAME_METHOD rtems_string_to_int
|
||||
#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_int"
|
||||
#define TEST_TOO_LARGE_STRING "987654321123456789123456789"
|
||||
#define TEST_TOO_SMALL_STRING "-98765432198765432123456789"
|
||||
#define STRING_TO_INTEGER
|
||||
#include "stringto_test_template.h"
|
||||
|
||||
@@ -117,6 +119,7 @@
|
||||
#define STRING_TO_NAME_METHOD rtems_string_to_float
|
||||
#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_float"
|
||||
#define TEST_TOO_LARGE_STRING "9.87654321123456789123456789E10240"
|
||||
#define TEST_TOO_SMALL_STRING "-9.87654321123456789123456789E10240"
|
||||
#define STRING_TO_FLOAT
|
||||
#include "stringto_test_template.h"
|
||||
|
||||
@@ -126,6 +129,7 @@
|
||||
#define STRING_TO_NAME_METHOD rtems_string_to_double
|
||||
#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_double"
|
||||
#define TEST_TOO_LARGE_STRING "9.87654321123456789123456789E10240"
|
||||
#define TEST_TOO_SMALL_STRING "-9.87654321123456789123456789E10240"
|
||||
#define STRING_TO_FLOAT
|
||||
#include "stringto_test_template.h"
|
||||
|
||||
|
||||
@@ -28,4 +28,4 @@ Directives:
|
||||
|
||||
Concepts:
|
||||
|
||||
+ Exhaustively test strong to number conversion helpers.
|
||||
+ Exhaustively test string to number conversion helpers.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
*** STRING TO CONVERSION TEST ***
|
||||
|
||||
Testing rtems_string_to_pointer
|
||||
@@ -13,6 +15,8 @@ rtems_string_to_unsigned_char - 123 NULL endptr return value - RTEMS_SUCCESSFUL
|
||||
rtems_string_to_unsigned_char - 123 w/endptr return value - RTEMS_SUCCESSFUL
|
||||
rtems_string_to_unsigned_char - YYY w/endptr return value - RTEMS_NOT_DEFINED
|
||||
rtems_string_to_unsigned_char - empty string - w/endptr return value - RTEMS_NOT_DEFINED
|
||||
rtems_string_to_unsigned_char - overflow - RTEMS_INVALID_NUMBER
|
||||
rtems_string_to_unsigned_char - overflow - RTEMS_INVALID_NUMBER
|
||||
|
||||
Testing rtems_string_to_int
|
||||
rtems_string_to_int - NULL return value - RTEMS_INVALID_ADDRESS
|
||||
@@ -22,6 +26,7 @@ rtems_string_to_int - 123 w/endptr return value - RTEMS_SUCCESSFUL
|
||||
rtems_string_to_int - YYY w/endptr return value - RTEMS_NOT_DEFINED
|
||||
rtems_string_to_int - empty string - w/endptr return value - RTEMS_NOT_DEFINED
|
||||
rtems_string_to_int - overflow - RTEMS_INVALID_NUMBER
|
||||
rtems_string_to_int- RTEMS_INVALID_NUMBER
|
||||
|
||||
Testing rtems_string_to_unsigned_int
|
||||
rtems_string_to_unsigned_int - NULL return value - RTEMS_INVALID_ADDRESS
|
||||
@@ -74,6 +79,7 @@ rtems_string_to_float - 1.23 w/endptr return value - RTEMS_SUCCESSFUL
|
||||
rtems_string_to_float - zzz w/endptr return value - RTEMS_NOT_DEFINED
|
||||
rtems_string_to_float - empty string - w/endptr return value - RTEMS_NOT_DEFINED
|
||||
rtems_string_to_float - overflow - RTEMS_INVALID_NUMBER
|
||||
rtems_string_to_float- RTEMS_INVALID_NUMBER
|
||||
|
||||
Testing rtems_string_to_double
|
||||
rtems_string_to_double - NULL return value - RTEMS_INVALID_ADDRESS
|
||||
@@ -82,4 +88,5 @@ rtems_string_to_double - 1.23 w/endptr return value - RTEMS_SUCCESSFUL
|
||||
rtems_string_to_double - zzz w/endptr return value - RTEMS_NOT_DEFINED
|
||||
rtems_string_to_double - empty string - w/endptr return value - RTEMS_NOT_DEFINED
|
||||
rtems_string_to_double - overflow - RTEMS_INVALID_NUMBER
|
||||
rtems_string_to_double- RTEMS_INVALID_NUMBER
|
||||
*** END OF STRING TO CONVERSION TEST ***
|
||||
|
||||
@@ -139,6 +139,23 @@ void TEST_STRING_TO_NAME(void)
|
||||
rtems_test_assert( endptr );
|
||||
#endif
|
||||
|
||||
|
||||
/* Conversion of number that is too large for unsigned char */
|
||||
#if defined(TEST_TOO_LARGE_FOR_UCHAR)
|
||||
endptr = NULL;
|
||||
value = 0;
|
||||
puts(
|
||||
STRING_TO_NAME_METHOD_STRING " - overflow - RTEMS_INVALID_NUMBER" );
|
||||
#if defined(STRING_TO_INTEGER)
|
||||
status = STRING_TO_NAME_METHOD(
|
||||
TEST_TOO_LARGE_FOR_UCHAR, &value, &endptr, 10 );
|
||||
#endif
|
||||
if ( status != RTEMS_INVALID_NUMBER )
|
||||
printf( "ERROR = %s\n", rtems_status_text(status) );
|
||||
rtems_test_assert( status == RTEMS_INVALID_NUMBER );
|
||||
rtems_test_assert( endptr );
|
||||
#endif
|
||||
|
||||
/* Conversion of number that is too small */
|
||||
#if defined(TEST_TOO_SMALL_STRING)
|
||||
endptr = NULL;
|
||||
@@ -170,3 +187,4 @@ void TEST_STRING_TO_NAME(void)
|
||||
#undef BAD_VALUE_STRING
|
||||
#undef TEST_TOO_LARGE_STRING
|
||||
#undef TEST_TOO_SMALL_STRING
|
||||
#undef TEST_TOO_LARGE_FOR_UCHAR
|
||||
|
||||
Reference in New Issue
Block a user