1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // test <cstdlib>
11
12 #include <cstdlib>
13 #include <type_traits>
14
15 #ifndef EXIT_FAILURE
16 #error EXIT_FAILURE not defined
17 #endif
18
19 #ifndef EXIT_SUCCESS
20 #error EXIT_SUCCESS not defined
21 #endif
22
23 #ifndef MB_CUR_MAX
24 #error MB_CUR_MAX not defined
25 #endif
26
27 #ifndef NULL
28 #error NULL not defined
29 #endif
30
31 #ifndef RAND_MAX
32 #error RAND_MAX not defined
33 #endif
34
main()35 int main()
36 {
37 std::size_t s = 0;
38 std::div_t d;
39 std::ldiv_t ld;
40 std::lldiv_t lld;
41 char** endptr = 0;
42 static_assert((std::is_same<decltype(std::atof("")), double>::value), "");
43 static_assert((std::is_same<decltype(std::atoi("")), int>::value), "");
44 static_assert((std::is_same<decltype(std::atol("")), long>::value), "");
45 static_assert((std::is_same<decltype(std::atoll("")), long long>::value), "");
46 static_assert((std::is_same<decltype(std::getenv("")), char*>::value), "");
47 static_assert((std::is_same<decltype(std::strtod("", endptr)), double>::value), "");
48 static_assert((std::is_same<decltype(std::strtof("", endptr)), float>::value), "");
49 static_assert((std::is_same<decltype(std::strtold("", endptr)), long double>::value), "");
50 static_assert((std::is_same<decltype(std::strtol("", endptr,0)), long>::value), "");
51 static_assert((std::is_same<decltype(std::strtoll("", endptr,0)), long long>::value), "");
52 static_assert((std::is_same<decltype(std::strtoul("", endptr,0)), unsigned long>::value), "");
53 static_assert((std::is_same<decltype(std::strtoull("", endptr,0)), unsigned long long>::value), "");
54 static_assert((std::is_same<decltype(std::rand()), int>::value), "");
55 static_assert((std::is_same<decltype(std::srand(0)), void>::value), "");
56 static_assert((std::is_same<decltype(std::calloc(0,0)), void*>::value), "");
57 static_assert((std::is_same<decltype(std::free(0)), void>::value), "");
58 static_assert((std::is_same<decltype(std::malloc(0)), void*>::value), "");
59 static_assert((std::is_same<decltype(std::realloc(0,0)), void*>::value), "");
60 static_assert((std::is_same<decltype(std::abort()), void>::value), "");
61 static_assert((std::is_same<decltype(std::atexit(0)), int>::value), "");
62 static_assert((std::is_same<decltype(std::exit(0)), void>::value), "");
63 static_assert((std::is_same<decltype(std::_Exit(0)), void>::value), "");
64 static_assert((std::is_same<decltype(std::getenv("")), char*>::value), "");
65 static_assert((std::is_same<decltype(std::system("")), int>::value), "");
66 static_assert((std::is_same<decltype(std::bsearch(0,0,0,0,0)), void*>::value), "");
67 static_assert((std::is_same<decltype(std::qsort(0,0,0,0)), void>::value), "");
68 static_assert((std::is_same<decltype(std::abs(0)), int>::value), "");
69 static_assert((std::is_same<decltype(std::abs((long)0)), long>::value), "");
70 static_assert((std::is_same<decltype(std::abs((long long)0)), long long>::value), "");
71 static_assert((std::is_same<decltype(std::labs((long)0)), long>::value), "");
72 static_assert((std::is_same<decltype(std::llabs((long long)0)), long long>::value), "");
73 static_assert((std::is_same<decltype(std::div(0,0)), std::div_t>::value), "");
74 static_assert((std::is_same<decltype(std::div(0L,0L)), std::ldiv_t>::value), "");
75 static_assert((std::is_same<decltype(std::div(0LL,0LL)), std::lldiv_t>::value), "");
76 static_assert((std::is_same<decltype(std::ldiv(0L,0L)), std::ldiv_t>::value), "");
77 static_assert((std::is_same<decltype(std::lldiv(0LL,0LL)), std::lldiv_t>::value), "");
78 static_assert((std::is_same<decltype(std::mblen("",0)), int>::value), "");
79 wchar_t* pw = 0;
80 const wchar_t* pwc = 0;
81 char* pc = 0;
82 static_assert((std::is_same<decltype(std::mbtowc(pw,"",0)), int>::value), "");
83 static_assert((std::is_same<decltype(std::wctomb(pc,L' ')), int>::value), "");
84 static_assert((std::is_same<decltype(std::mbstowcs(pw,"",0)), std::size_t>::value), "");
85 static_assert((std::is_same<decltype(std::wcstombs(pc,pwc,0)), std::size_t>::value), "");
86 }
87