File indexing completed on 2025-05-11 08:24:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include "tmacros.h"
0034 #include <rtems/stringto.h>
0035 #include <limits.h>
0036 #include <math.h>
0037
0038 #include <stdio.h>
0039
0040 const char rtems_test_name[] = "STRINGTO 1";
0041
0042
0043 rtems_task Init(rtems_task_argument argument);
0044
0045 #define __STRING(x) #x
0046 #define __XSTRING(x) __STRING(x)
0047
0048 static int get_base_10_or_16(const char *s)
0049 {
0050 return (s[0] == '0' && s[1] == 'x') ? 16 : 10;
0051 }
0052
0053
0054 #ifndef LONG_LONG_MAX
0055 #define LONG_LONG_MAX LLONG_MAX
0056 #endif
0057
0058 #ifndef LONG_LONG_MIN
0059 #define LONG_LONG_MIN LLONG_MIN
0060 #endif
0061
0062
0063 #define TEST_STRING_TO_TYPE void *
0064 #define TEST_STRING_TO_NAME test_rtems_string_to_pointer
0065 #define STRING_TO_NAME_METHOD rtems_string_to_pointer
0066 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_pointer"
0067 #define STRING_TO_POINTER
0068 #include "stringto_test_template.h"
0069
0070
0071 #define TEST_STRING_TO_TYPE unsigned char
0072 #define TEST_STRING_TO_NAME test_rtems_string_to_unsigned_char
0073 #define STRING_TO_NAME_METHOD rtems_string_to_unsigned_char
0074 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_char"
0075 #define TEST_TOO_LARGE_STRING "987654321123456789123456789"
0076 #define TEST_TOO_LARGE_FOR_UCHAR "256"
0077 #define STRING_TO_INTEGER
0078 #include "stringto_test_template.h"
0079
0080
0081 #define TEST_STRING_TO_TYPE int
0082 #define STRING_TO_MAX INT_MAX
0083 #define STRING_TO_MAX_STRING __XSTRING(INT_MAX)
0084 #define TEST_STRING_TO_NAME test_rtems_string_to_int
0085 #define STRING_TO_NAME_METHOD rtems_string_to_int
0086 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_int"
0087 #define TEST_TOO_LARGE_STRING "987654321123456789123456789"
0088 #define TEST_TOO_SMALL_STRING "-98765432198765432123456789"
0089 #define STRING_TO_INTEGER
0090 #include "stringto_test_template.h"
0091
0092
0093 #define TEST_STRING_TO_TYPE unsigned int
0094 #define TEST_STRING_TO_NAME test_rtems_string_to_unsigned_int
0095 #define STRING_TO_NAME_METHOD rtems_string_to_unsigned_int
0096 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_int"
0097 #define TEST_TOO_LARGE_STRING "987654321123456789123456789"
0098 #define STRING_TO_INTEGER
0099 #include "stringto_test_template.h"
0100
0101
0102 #define TEST_STRING_TO_TYPE long
0103 #define STRING_TO_MAX LONG_MAX
0104 #define STRING_TO_MAX_STRING __XSTRING(LONG_MAX)
0105 #define TEST_STRING_TO_NAME test_rtems_string_to_long
0106 #define STRING_TO_NAME_METHOD rtems_string_to_long
0107 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_long"
0108 #define TEST_TOO_LARGE_STRING "987654321123456789123456789"
0109 #define TEST_TOO_SMALL_STRING "-98765432198765432123456789"
0110 #define STRING_TO_INTEGER
0111 #include "stringto_test_template.h"
0112
0113
0114 #define TEST_STRING_TO_TYPE unsigned long
0115 #define TEST_STRING_TO_NAME test_rtems_string_to_unsigned_long
0116 #define STRING_TO_NAME_METHOD rtems_string_to_unsigned_long
0117 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_long"
0118 #define TEST_TOO_LARGE_STRING "987654321123456789123456789"
0119 #define STRING_TO_INTEGER
0120 #include "stringto_test_template.h"
0121
0122
0123 #define TEST_STRING_TO_TYPE long long
0124 #define STRING_TO_MAX LONG_LONG_MAX
0125 #define STRING_TO_MAX_STRING __XSTRING(LONG_LONG_MAX)
0126 #define TEST_STRING_TO_NAME test_rtems_string_to_long_long
0127 #define STRING_TO_NAME_METHOD rtems_string_to_long_long
0128 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_long_long"
0129 #define TEST_TOO_LARGE_STRING "987654321123456789123456789"
0130 #define TEST_TOO_SMALL_STRING "-98765432198765432123456789"
0131 #define STRING_TO_INTEGER
0132 #include "stringto_test_template.h"
0133
0134
0135 #define TEST_STRING_TO_TYPE unsigned long long
0136 #define TEST_STRING_TO_NAME test_rtems_string_to_unsigned_long_long
0137 #define STRING_TO_NAME_METHOD rtems_string_to_unsigned_long_long
0138 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_long_long"
0139 #define TEST_TOO_LARGE_STRING "987654321123456789123456789"
0140 #define STRING_TO_INTEGER
0141 #include "stringto_test_template.h"
0142
0143
0144 #define TEST_STRING_TO_TYPE float
0145 #define TEST_STRING_TO_NAME test_rtems_string_to_float
0146 #define STRING_TO_NAME_METHOD rtems_string_to_float
0147 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_float"
0148 #define TEST_TOO_LARGE_STRING "9.87654321123456789123456789E10240"
0149 #define TEST_TOO_SMALL_STRING "-9.87654321123456789123456789E10240"
0150 #define STRING_TO_FLOAT
0151 #include "stringto_test_template.h"
0152
0153
0154 #define TEST_STRING_TO_TYPE double
0155 #define TEST_STRING_TO_NAME test_rtems_string_to_double
0156 #define STRING_TO_NAME_METHOD rtems_string_to_double
0157 #define STRING_TO_NAME_METHOD_STRING "rtems_string_to_double"
0158 #define TEST_TOO_LARGE_STRING "9.87654321123456789123456789E10240"
0159 #define TEST_TOO_SMALL_STRING "-9.87654321123456789123456789E10240"
0160 #define STRING_TO_FLOAT
0161 #include "stringto_test_template.h"
0162
0163 rtems_task Init(
0164 rtems_task_argument ignored
0165 )
0166 {
0167 TEST_BEGIN();
0168 test_rtems_string_to_pointer();
0169 test_rtems_string_to_unsigned_char();
0170 test_rtems_string_to_int();
0171 test_rtems_string_to_unsigned_int();
0172 test_rtems_string_to_long();
0173 test_rtems_string_to_unsigned_long();
0174 test_rtems_string_to_long_long();
0175 test_rtems_string_to_unsigned_long_long();
0176
0177 test_rtems_string_to_float();
0178 test_rtems_string_to_double();
0179 TEST_END();
0180 rtems_test_exit(0);
0181 }
0182
0183
0184 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0185 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0186
0187 #define CONFIGURE_MAXIMUM_TASKS 1
0188
0189 #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
0190 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0191
0192 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0193
0194 #define CONFIGURE_INIT
0195 #include <rtems/confdefs.h>