literals1.pass.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03, c++11
  10. #include <chrono>
  11. #include <cassert>
  12. #include "test_macros.h"
  13. int main(int, char**)
  14. {
  15. using namespace std::chrono;
  16. hours h = 4h;
  17. assert ( h == hours(4));
  18. auto h2 = 4.0h;
  19. assert ( h == h2 );
  20. minutes min = 36min;
  21. assert ( min == minutes(36));
  22. auto min2 = 36.0min;
  23. assert ( min == min2 );
  24. seconds s = 24s;
  25. assert ( s == seconds(24));
  26. auto s2 = 24.0s;
  27. assert ( s == s2 );
  28. milliseconds ms = 247ms;
  29. assert ( ms == milliseconds(247));
  30. auto ms2 = 247.0ms;
  31. assert ( ms == ms2 );
  32. microseconds us = 867us;
  33. assert ( us == microseconds(867));
  34. auto us2 = 867.0us;
  35. assert ( us == us2 );
  36. nanoseconds ns = 645ns;
  37. assert ( ns == nanoseconds(645));
  38. auto ns2 = 645.ns;
  39. assert ( ns == ns2 );
  40. #if TEST_STD_VER > 17
  41. assert(Sunday == weekday(0));
  42. assert(Monday == weekday(1));
  43. assert(Tuesday == weekday(2));
  44. assert(Wednesday == weekday(3));
  45. assert(Thursday == weekday(4));
  46. assert(Friday == weekday(5));
  47. assert(Saturday == weekday(6));
  48. assert(January == month(1));
  49. assert(February == month(2));
  50. assert(March == month(3));
  51. assert(April == month(4));
  52. assert(May == month(5));
  53. assert(June == month(6));
  54. assert(July == month(7));
  55. assert(August == month(8));
  56. assert(September == month(9));
  57. assert(October == month(10));
  58. assert(November == month(11));
  59. assert(December == month(12));
  60. #endif
  61. return 0;
  62. }