15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier
95a83710eSEric Fiselier // test <ctime>
105a83710eSEric Fiselier
115a83710eSEric Fiselier #include <ctime>
125a83710eSEric Fiselier #include <type_traits>
13deb471faSMarshall Clow #include "test_macros.h"
145a83710eSEric Fiselier
155a83710eSEric Fiselier #ifndef NULL
165a83710eSEric Fiselier #error NULL not defined
175a83710eSEric Fiselier #endif
185a83710eSEric Fiselier
195a83710eSEric Fiselier #ifndef CLOCKS_PER_SEC
205a83710eSEric Fiselier #error CLOCKS_PER_SEC not defined
215a83710eSEric Fiselier #endif
225a83710eSEric Fiselier
main(int,char **)232df59c50SJF Bastien int main(int, char**)
245a83710eSEric Fiselier {
255a83710eSEric Fiselier std::clock_t c = 0;
265a83710eSEric Fiselier std::size_t s = 0;
275a83710eSEric Fiselier std::time_t t = 0;
283245e1f3SEric Fiselier std::tm tm = {};
29*ec574f5dSLouis Dionne // std::timespec and std::timespec_get tested in ctime.timespec.compile.pass.cpp
30fb42f4c4SEric Fiselier ((void)c); // Prevent unused warning
31fb42f4c4SEric Fiselier ((void)s); // Prevent unused warning
32fb42f4c4SEric Fiselier ((void)t); // Prevent unused warning
33fb42f4c4SEric Fiselier ((void)tm); // Prevent unused warning
345a83710eSEric Fiselier static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");
355a83710eSEric Fiselier static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
365a83710eSEric Fiselier static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
375a83710eSEric Fiselier static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
385a83710eSEric Fiselier static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
395a83710eSEric Fiselier static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
405a83710eSEric Fiselier static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
415a83710eSEric Fiselier static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
425a83710eSEric Fiselier char* c1 = 0;
435a83710eSEric Fiselier const char* c2 = 0;
44fb42f4c4SEric Fiselier ((void)c1); // Prevent unused warning
45fb42f4c4SEric Fiselier ((void)c2); // Prevent unused warning
465a83710eSEric Fiselier static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), "");
472df59c50SJF Bastien
482df59c50SJF Bastien return 0;
495a83710eSEric Fiselier }
50