source: rtems/testsuites/libtests/stringto01/init.c @ e41e75de

4.115
Last change on this file since e41e75de was e41e75de, checked in by Joel Sherrill <joel.sherrill@…>, on 07/19/10 at 13:10:48

2010-07-19 Joel Sherrill <joel.sherrill@…>

  • stringto01/init.c, stringto01/stringto01.scn, stringto01/stringto_test_template.h: Attempt to pick up a few more error paths.
  • Property mode set to 100644
File size: 5.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
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.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#include "tmacros.h"
13#include <rtems/stringto.h>
14#include <limits.h>
15#include <math.h>
16
17#include <stdio.h>
18
19#define __STRING(x)     #x              /* stringify without expanding x */
20#define __XSTRING(x)    __STRING(x)     /* expand x, then stringify */
21
22/* Test pointer conversions */
23#define TEST_STRING_TO_TYPE          void *
24#define TEST_STRING_TO_NAME          test_rtems_string_to_pointer
25#define STRING_TO_NAME_METHOD        rtems_string_to_pointer
26#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_pointer"
27#define STRING_TO_POINTER
28#include "stringto_test_template.h"
29
30/* Test unsigned char conversions */
31#define TEST_STRING_TO_TYPE          unsigned char
32#define TEST_STRING_TO_NAME          test_rtems_string_to_unsigned_char
33#define STRING_TO_NAME_METHOD        rtems_string_to_unsigned_char
34#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_char"
35/* #define TEST_TOO_LARGE_STRING        "987654321123456789123456789" */
36#define STRING_TO_INTEGER
37#include "stringto_test_template.h"
38
39/* Test integer conversions */
40#define TEST_STRING_TO_TYPE          int
41#define STRING_TO_MAX                LONG_MAX
42#define STRING_TO_MAX_STRING         __XSTRING(LONG_MAX)
43#define TEST_STRING_TO_NAME          test_rtems_string_to_int
44#define STRING_TO_NAME_METHOD        rtems_string_to_int
45#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_int"
46#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
47#define STRING_TO_INTEGER
48#include "stringto_test_template.h"
49
50/* Test unsigned int conversions */
51#define TEST_STRING_TO_TYPE          unsigned int
52#define TEST_STRING_TO_NAME          test_rtems_string_to_unsigned_int
53#define STRING_TO_NAME_METHOD        rtems_string_to_unsigned_int
54#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_int"
55#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
56#define STRING_TO_INTEGER
57#include "stringto_test_template.h"
58
59/* Test long conversions */
60#define TEST_STRING_TO_TYPE          long
61#define STRING_TO_MAX                LONG_MAX
62#define STRING_TO_MAX_STRING         __XSTRING(LONG_MAX)
63#define TEST_STRING_TO_NAME          test_rtems_string_to_long
64#define STRING_TO_NAME_METHOD        rtems_string_to_long
65#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_long"
66#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
67#define TEST_TOO_SMALL_STRING        "-98765432198765432123456789"
68#define STRING_TO_INTEGER
69#include "stringto_test_template.h"
70
71/* Test unsigned long conversions */
72#define TEST_STRING_TO_TYPE          unsigned long
73#define TEST_STRING_TO_NAME          test_rtems_string_to_unsigned_long
74#define STRING_TO_NAME_METHOD        rtems_string_to_unsigned_long
75#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_long"
76#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
77#define STRING_TO_INTEGER
78#include "stringto_test_template.h"
79
80/* Test long long conversions */
81#define TEST_STRING_TO_TYPE          long long
82#define STRING_TO_MAX                LONG_LONG_MAX
83#define STRING_TO_MAX_STRING         __XSTRING(LONG_LONG_MAX)
84#define TEST_STRING_TO_NAME          test_rtems_string_to_long_long
85#define STRING_TO_NAME_METHOD        rtems_string_to_long_long
86#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_long_long"
87#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
88#define TEST_TOO_SMALL_STRING        "-98765432198765432123456789"
89#define STRING_TO_INTEGER
90#include "stringto_test_template.h"
91
92/* Test unsigned long long conversions */
93#define TEST_STRING_TO_TYPE          unsigned long long
94#define TEST_STRING_TO_NAME          test_rtems_string_to_unsigned_long_long
95#define STRING_TO_NAME_METHOD        rtems_string_to_unsigned_long_long
96#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_unsigned_long_long"
97#define TEST_TOO_LARGE_STRING        "987654321123456789123456789"
98#define STRING_TO_INTEGER
99#include "stringto_test_template.h"
100
101/* Test float conversions */
102#define TEST_STRING_TO_TYPE          float
103#define TEST_STRING_TO_NAME          test_rtems_string_to_float
104#define STRING_TO_NAME_METHOD        rtems_string_to_float
105#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_float"
106#define TEST_TOO_LARGE_STRING        "9.87654321123456789123456789E10240"
107#define STRING_TO_FLOAT
108#include "stringto_test_template.h"
109
110/* Test double conversions */
111#define TEST_STRING_TO_TYPE          double
112#define TEST_STRING_TO_NAME          test_rtems_string_to_double
113#define STRING_TO_NAME_METHOD        rtems_string_to_double
114#define STRING_TO_NAME_METHOD_STRING "rtems_string_to_double"
115#define TEST_TOO_LARGE_STRING        "9.87654321123456789123456789E10240"
116#define STRING_TO_FLOAT
117#include "stringto_test_template.h"
118
119rtems_task Init(
120  rtems_task_argument ignored
121)
122{
123  puts( "\n\n*** STRING TO CONVERSION TEST ***" );
124  test_rtems_string_to_pointer();
125  test_rtems_string_to_unsigned_char();
126  test_rtems_string_to_int();
127  test_rtems_string_to_unsigned_int();
128  test_rtems_string_to_long();
129  test_rtems_string_to_unsigned_long();
130  test_rtems_string_to_long_long();
131  test_rtems_string_to_unsigned_long_long();
132
133  test_rtems_string_to_float();
134  test_rtems_string_to_double();
135  puts( "*** END OF STRING TO CONVERSION TEST ***" );
136  rtems_test_exit(0);
137}
138
139/* NOTICE: the clock driver is explicitly disabled */
140#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
141#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
142
143#define CONFIGURE_MAXIMUM_TASKS            1
144#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
145
146#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
147#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
148
149#define CONFIGURE_INIT
150#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.