1 /*
2 * Copyright (C) 2009 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29
30 #include <climits>
31 #if defined BIONIC && !defined BIONIC_LIBSTDCPP_INCLUDE_CLIMITS__
32 #error "Wrong header file included!!"
33 #endif
34
35
36 namespace {
37 const int kPassed = 0;
38 const int kFailed = 1;
39 #define FAIL_UNLESS(f) if (!android::f()) return kFailed;
40 } // anonymous namespace
41
42 namespace android
43 {
testLimits()44 bool testLimits()
45 {
46 // char
47 volatile char c1 = CHAR_BIT;
48 volatile char c2 = CHAR_MAX;
49 volatile char c3 = CHAR_MIN;
50
51 // int
52 volatile int i1 = INT_MAX;
53 volatile int i2 = INT_MIN;
54
55 // short
56 volatile short s1 = SHRT_MAX;
57 volatile short s2 = SHRT_MIN;
58
59 // long
60 volatile long l1 = LONG_MAX;
61 volatile long l2 = LONG_MIN;
62
63 // long long
64 volatile long long ll1 = LLONG_MAX;
65 volatile long long ll2 = LLONG_MIN;
66
67 volatile unsigned long mb = MB_LEN_MAX;
68
69 // signed char
70 volatile signed char sc1 = SCHAR_MIN;
71 volatile signed char sc2 = SCHAR_MAX;
72
73 // unsigned
74 volatile unsigned int ui = UINT_MAX;
75 volatile unsigned short us = USHRT_MAX;
76 volatile unsigned long ul = ULONG_MAX;
77 volatile unsigned long long ull = ULLONG_MAX;
78
79 return true;
80 }
81
82 } // namespace android
83
main(int argc,char ** argv)84 int main(int argc, char **argv)
85 {
86 FAIL_UNLESS(testLimits);
87 return kPassed;
88 }
89