op_equal.pass.cpp revision c52f43e72dfcea03037729649da84c23b3beb04a
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <chrono> 11 12// duration 13 14// template <class Rep1, class Period1, class Rep2, class Period2> 15// bool 16// operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 17 18// template <class Rep1, class Period1, class Rep2, class Period2> 19// bool 20// operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 21 22#include <chrono> 23#include <cassert> 24 25int main() 26{ 27 { 28 std::chrono::seconds s1(3); 29 std::chrono::seconds s2(3); 30 assert(s1 == s2); 31 assert(!(s1 != s2)); 32 } 33 { 34 std::chrono::seconds s1(3); 35 std::chrono::seconds s2(4); 36 assert(!(s1 == s2)); 37 assert(s1 != s2); 38 } 39 { 40 std::chrono::milliseconds s1(3); 41 std::chrono::microseconds s2(3000); 42 assert(s1 == s2); 43 assert(!(s1 != s2)); 44 } 45 { 46 std::chrono::milliseconds s1(3); 47 std::chrono::microseconds s2(4000); 48 assert(!(s1 == s2)); 49 assert(s1 != s2); 50 } 51 { 52 std::chrono::duration<int, std::ratio<2, 3> > s1(9); 53 std::chrono::duration<int, std::ratio<3, 5> > s2(10); 54 assert(s1 == s2); 55 assert(!(s1 != s2)); 56 } 57 { 58 std::chrono::duration<int, std::ratio<2, 3> > s1(10); 59 std::chrono::duration<int, std::ratio<3, 5> > s2(9); 60 assert(!(s1 == s2)); 61 assert(s1 != s2); 62 } 63 { 64 std::chrono::duration<int, std::ratio<2, 3> > s1(9); 65 std::chrono::duration<double, std::ratio<3, 5> > s2(10); 66 assert(s1 == s2); 67 assert(!(s1 != s2)); 68 } 69} 70