source: rtems/testsuites/libtests/stringto01/init.c @ 54e7b81

5
Last change on this file since 54e7b81 was 54e7b81, checked in by Sebastian Huber <sebastian.huber@…>, on 11/24/17 at 14:18:14

libtests/stringto01: Fix 64-bit targets

Update #3082.

  • Property mode set to 100644
File size: 6.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include "tmacros.h"
15#include <rtems/stringto.h>
16#include <limits.h>
17#include <math.h>
18
19#include <stdio.h>
20
21const char rtems_test_name[] = "STRINGTO 1";
22
23/* forward declarations to avoid warnings */
24rtems_task Init(rtems_task_argument argument);
25
26#define __STRING(x)     #x              /* stringify without expanding x */
27#define __XSTRING(x)    __STRING(x)     /* expand x, then stringify */
28
29static int get_base_10_or_16(const char *s)
30{
31  return (s[0] == '0' && s[1] == 'x') ? 16 : 10;
32}
33
34/* c99 has LLONG_MAX instead of LONG_LONG_MAX */
35#ifndef LONG_LONG_MAX
36#define LONG_LONG_MAX   LLONG_MAX
37#endif
38/* c99 has LLONG_MIN instead of LONG_LONG_MIN */
39#ifndef LONG_LONG_MIN
40#define LONG_LONG_MIN   LLONG_MIN
41#endif
42
43/* Test pointer conversions */
44#define TEST_STRING_TO_TYPE          void *
45#define TEST_STRING_TO_NAME          test_rtems_string_to_pointer
46#define STRING_TO_NAME_METHOD        rtems_string_to_pointer
47#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_pointer"
48#define STRING_TO_POINTER
49#include "stringto_test_template.h"
50
51/* Test unsigned char conversions */
52#define TEST_STRING_TO_TYPE          unsigned char
53#define TEST_STRING_TO_NAME          test_rtems_string_to_unsigned_char
54#define STRING_TO_NAME_METHOD        rtems_string_to_unsigned_char
55#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_char"
56#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
57#define TEST_TOO_LARGE_FOR_UCHAR     "256"
58#define STRING_TO_INTEGER
59#include "stringto_test_template.h"
60
61/* Test integer conversions */
62#define TEST_STRING_TO_TYPE          int
63#define STRING_TO_MAX                INT_MAX
64#define STRING_TO_MAX_STRING         __XSTRING(INT_MAX)
65#define TEST_STRING_TO_NAME          test_rtems_string_to_int
66#define STRING_TO_NAME_METHOD        rtems_string_to_int
67#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_int"
68#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
69#define TEST_TOO_SMALL_STRING        "-98765432198765432123456789"
70#define STRING_TO_INTEGER
71#include "stringto_test_template.h"
72
73/* Test unsigned int conversions */
74#define TEST_STRING_TO_TYPE          unsigned int
75#define TEST_STRING_TO_NAME          test_rtems_string_to_unsigned_int
76#define STRING_TO_NAME_METHOD        rtems_string_to_unsigned_int
77#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_int"
78#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
79#define STRING_TO_INTEGER
80#include "stringto_test_template.h"
81
82/* Test long conversions */
83#define TEST_STRING_TO_TYPE          long
84#define STRING_TO_MAX                LONG_MAX
85#define STRING_TO_MAX_STRING         __XSTRING(LONG_MAX)
86#define TEST_STRING_TO_NAME          test_rtems_string_to_long
87#define STRING_TO_NAME_METHOD        rtems_string_to_long
88#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_long"
89#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
90#define TEST_TOO_SMALL_STRING        "-98765432198765432123456789"
91#define STRING_TO_INTEGER
92#include "stringto_test_template.h"
93
94/* Test unsigned long conversions */
95#define TEST_STRING_TO_TYPE          unsigned long
96#define TEST_STRING_TO_NAME          test_rtems_string_to_unsigned_long
97#define STRING_TO_NAME_METHOD        rtems_string_to_unsigned_long
98#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_long"
99#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
100#define STRING_TO_INTEGER
101#include "stringto_test_template.h"
102
103/* Test long long conversions */
104#define TEST_STRING_TO_TYPE          long long
105#define STRING_TO_MAX                LONG_LONG_MAX
106#define STRING_TO_MAX_STRING         __XSTRING(LONG_LONG_MAX)
107#define TEST_STRING_TO_NAME          test_rtems_string_to_long_long
108#define STRING_TO_NAME_METHOD        rtems_string_to_long_long
109#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_long_long"
110#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
111#define TEST_TOO_SMALL_STRING        "-98765432198765432123456789"
112#define STRING_TO_INTEGER
113#include "stringto_test_template.h"
114
115/* Test unsigned long long conversions */
116#define TEST_STRING_TO_TYPE          unsigned long long
117#define TEST_STRING_TO_NAME          test_rtems_string_to_unsigned_long_long
118#define STRING_TO_NAME_METHOD        rtems_string_to_unsigned_long_long
119#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_long_long"
120#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
121#define STRING_TO_INTEGER
122#include "stringto_test_template.h"
123
124/* Test float conversions */
125#define TEST_STRING_TO_TYPE          float
126#define TEST_STRING_TO_NAME          test_rtems_string_to_float
127#define STRING_TO_NAME_METHOD        rtems_string_to_float
128#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_float"
129#define TEST_TOO_LARGE_STRING        "9.87654321123456789123456789E10240"
130#define TEST_TOO_SMALL_STRING        "-9.87654321123456789123456789E10240"
131#define STRING_TO_FLOAT
132#include "stringto_test_template.h"
133
134/* Test double conversions */
135#define TEST_STRING_TO_TYPE          double
136#define TEST_STRING_TO_NAME          test_rtems_string_to_double
137#define STRING_TO_NAME_METHOD        rtems_string_to_double
138#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_double"
139#define TEST_TOO_LARGE_STRING        "9.87654321123456789123456789E10240"
140#define TEST_TOO_SMALL_STRING        "-9.87654321123456789123456789E10240"
141#define STRING_TO_FLOAT
142#include "stringto_test_template.h"
143
144rtems_task Init(
145  rtems_task_argument ignored
146)
147{
148  TEST_BEGIN();
149  test_rtems_string_to_pointer();
150  test_rtems_string_to_unsigned_char();
151  test_rtems_string_to_int();
152  test_rtems_string_to_unsigned_int();
153  test_rtems_string_to_long();
154  test_rtems_string_to_unsigned_long();
155  test_rtems_string_to_long_long();
156  test_rtems_string_to_unsigned_long_long();
157
158  test_rtems_string_to_float();
159  test_rtems_string_to_double();
160  TEST_END();
161  rtems_test_exit(0);
162}
163
164/* NOTICE: the clock driver is explicitly disabled */
165#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
166#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
167
168#define CONFIGURE_MAXIMUM_TASKS            1
169
170#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
171#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
172
173#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
174
175#define CONFIGURE_INIT
176#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.