Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // test <ctime> |
| 11 | |
| 12 | #include <ctime> |
| 13 | #include <type_traits> |
| 14 | |
| 15 | #ifndef NULL |
| 16 | #error NULL not defined |
| 17 | #endif |
| 18 | |
| 19 | #ifndef CLOCKS_PER_SEC |
| 20 | #error CLOCKS_PER_SEC not defined |
| 21 | #endif |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | std::clock_t c = 0; |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 26 | ((void)c); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 27 | std::size_t s = 0; |
| 28 | std::time_t t = 0; |
| 29 | std::tm tm = {0}; |
| 30 | static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), ""); |
| 31 | static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), ""); |
| 32 | static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), ""); |
| 33 | static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), ""); |
Ed Schouten | 323ade3 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 34 | #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 35 | static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), ""); |
| 36 | static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), ""); |
| 37 | static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), ""); |
| 38 | static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), ""); |
Ed Schouten | 323ade3 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 39 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 40 | char* c1 = 0; |
| 41 | const char* c2 = 0; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 42 | static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), ""); |
| 43 | } |