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 <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 23int main() 24{ 25 std::clock_t c = 0; 26 std::size_t s = 0; 27 std::time_t t = 0; 28 std::tm tm = {}; 29 ((void)c); // Prevent unused warning 30 ((void)s); // Prevent unused warning 31 ((void)t); // Prevent unused warning 32 ((void)tm); // Prevent unused warning 33 static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), ""); 34 static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), ""); 35 static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), ""); 36 static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), ""); 37#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS 38 static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), ""); 39 static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), ""); 40 static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), ""); 41 static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), ""); 42#endif 43 char* c1 = 0; 44 const char* c2 = 0; 45 ((void)c1); // Prevent unused warning 46 ((void)c2); // Prevent unused warning 47 static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), ""); 48} 49