50 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// test <ctime>10 11#include <ctime>12#include <type_traits>13#include "test_macros.h"14 15#ifndef NULL16#error NULL not defined17#endif18 19#ifndef CLOCKS_PER_SEC20#error CLOCKS_PER_SEC not defined21#endif22 23int main(int, char**)24{25 std::clock_t c = 0;26 std::size_t s = 0;27 std::time_t t = 0;28 std::tm tm = {};29 // std::timespec and std::timespec_get tested in ctime.timespec.compile.pass.cpp30 ((void)c); // Prevent unused warning31 ((void)s); // Prevent unused warning32 ((void)t); // Prevent unused warning33 ((void)tm); // Prevent unused warning34 static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");35 static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");36 static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");37 static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");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 char* c1 = 0;43 const char* c2 = 0;44 ((void)c1); // Prevent unused warning45 ((void)c2); // Prevent unused warning46 static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), "");47 48 return 0;49}50