mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-27 00:14:07 +08:00
Test is now C++11 compatible
This commit is contained in:
parent
db60c5eb8e
commit
4b687f4c04
@ -5,7 +5,6 @@ int
|
|||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
using namespace date;
|
using namespace date;
|
||||||
using namespace std::chrono_literals;
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
/// sys epoch
|
/// sys epoch
|
||||||
@ -13,7 +12,7 @@ main()
|
|||||||
auto ls = local_days{1970_y/01/01_d};
|
auto ls = local_days{1970_y/01/01_d};
|
||||||
auto st = clock_cast<system_clock>(ls);
|
auto st = clock_cast<system_clock>(ls);
|
||||||
assert(clock_cast<local_t>(st) == ls);
|
assert(clock_cast<local_t>(st) == ls);
|
||||||
assert(st.time_since_epoch() == 0s);
|
assert(st.time_since_epoch() == seconds(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// sys 2000 case
|
/// sys 2000 case
|
||||||
@ -21,7 +20,7 @@ main()
|
|||||||
auto ls = local_days{2000_y/01/01_d};
|
auto ls = local_days{2000_y/01/01_d};
|
||||||
auto st = clock_cast<system_clock>(ls);
|
auto st = clock_cast<system_clock>(ls);
|
||||||
assert(clock_cast<local_t>(st) == ls);
|
assert(clock_cast<local_t>(st) == ls);
|
||||||
assert(st.time_since_epoch() == 946'684'800s);
|
assert(st.time_since_epoch() == seconds(946684800));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ main()
|
|||||||
auto lu = local_days{1970_y/01/01_d};
|
auto lu = local_days{1970_y/01/01_d};
|
||||||
auto ut = clock_cast<utc_clock>(lu);
|
auto ut = clock_cast<utc_clock>(lu);
|
||||||
assert(clock_cast<local_t>(ut) == lu);
|
assert(clock_cast<local_t>(ut) == lu);
|
||||||
assert(ut.time_since_epoch() == 0s);
|
assert(ut.time_since_epoch() == seconds(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// utc paper example
|
/// utc paper example
|
||||||
@ -38,7 +37,7 @@ main()
|
|||||||
auto lu = local_days{2000_y/01/01_d};
|
auto lu = local_days{2000_y/01/01_d};
|
||||||
auto ut = clock_cast<utc_clock>(lu);
|
auto ut = clock_cast<utc_clock>(lu);
|
||||||
assert(clock_cast<local_t>(ut) == lu);
|
assert(clock_cast<local_t>(ut) == lu);
|
||||||
assert(ut.time_since_epoch() == 946'684'822s);
|
assert(ut.time_since_epoch() == seconds(946684822));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// tai epoch
|
/// tai epoch
|
||||||
@ -46,16 +45,16 @@ main()
|
|||||||
auto lt = local_days{1958_y/01/01_d};
|
auto lt = local_days{1958_y/01/01_d};
|
||||||
auto tt = clock_cast<tai_clock>(lt);
|
auto tt = clock_cast<tai_clock>(lt);
|
||||||
assert(clock_cast<local_t>(tt) == lt);
|
assert(clock_cast<local_t>(tt) == lt);
|
||||||
assert(tt.time_since_epoch() == 0s);
|
assert(tt.time_since_epoch() == seconds(0));
|
||||||
|
|
||||||
auto lu = local_days{1957_y/12/31_d} + 23h + 59min + 50s;
|
auto lu = local_days{1958_y/01/01_d} - seconds(10);
|
||||||
auto ut = clock_cast<utc_clock>(lu);
|
auto ut = clock_cast<utc_clock>(lu);
|
||||||
assert(clock_cast<tai_clock>(ut) == tt);
|
assert(clock_cast<tai_clock>(ut) == tt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// tai paper example
|
// tai paper example
|
||||||
{
|
{
|
||||||
auto lt = local_days{2000_y/01/01_d} + 32s;
|
auto lt = local_days{2000_y/01/01_d} + seconds(32);
|
||||||
auto tt = clock_cast<tai_clock>(lt);
|
auto tt = clock_cast<tai_clock>(lt);
|
||||||
assert(clock_cast<local_t>(tt) == lt);
|
assert(clock_cast<local_t>(tt) == lt);
|
||||||
|
|
||||||
@ -69,13 +68,13 @@ main()
|
|||||||
auto lg = local_days{1980_y/01/Sunday[1]};
|
auto lg = local_days{1980_y/01/Sunday[1]};
|
||||||
auto gt = clock_cast<gps_clock>(lg);
|
auto gt = clock_cast<gps_clock>(lg);
|
||||||
assert(clock_cast<local_t>(gt) == lg);
|
assert(clock_cast<local_t>(gt) == lg);
|
||||||
assert(gt.time_since_epoch() == 0s);
|
assert(gt.time_since_epoch() == seconds(0));
|
||||||
|
|
||||||
auto lu = local_days{1980_y/01/Sunday[1]};
|
auto lu = local_days{1980_y/01/Sunday[1]};
|
||||||
auto ut = clock_cast<utc_clock>(lu);
|
auto ut = clock_cast<utc_clock>(lu);
|
||||||
assert(clock_cast<gps_clock>(ut) == gt);
|
assert(clock_cast<gps_clock>(ut) == gt);
|
||||||
|
|
||||||
auto lt = local_days{1980_y/01/Sunday[1]} + 19s;
|
auto lt = local_days{1980_y/01/Sunday[1]} + seconds(19);
|
||||||
auto tt = clock_cast<tai_clock>(lt);
|
auto tt = clock_cast<tai_clock>(lt);
|
||||||
assert(clock_cast<gps_clock>(tt) == gt);
|
assert(clock_cast<gps_clock>(tt) == gt);
|
||||||
}
|
}
|
||||||
@ -86,11 +85,11 @@ main()
|
|||||||
auto gt = clock_cast<gps_clock>(lg);
|
auto gt = clock_cast<gps_clock>(lg);
|
||||||
assert(clock_cast<local_t>(gt) == lg);
|
assert(clock_cast<local_t>(gt) == lg);
|
||||||
|
|
||||||
auto lu = local_days{2000_y/01/01_d} - 13s;
|
auto lu = local_days{2000_y/01/01_d} - seconds(13);
|
||||||
auto ut = clock_cast<utc_clock>(lu);
|
auto ut = clock_cast<utc_clock>(lu);
|
||||||
assert(clock_cast<gps_clock>(ut) == gt);
|
assert(clock_cast<gps_clock>(ut) == gt);
|
||||||
|
|
||||||
auto lt = local_days{2000_y/01/01_d} + 19s;
|
auto lt = local_days{2000_y/01/01_d} + seconds(19);
|
||||||
auto tt = clock_cast<tai_clock>(lt);
|
auto tt = clock_cast<tai_clock>(lt);
|
||||||
assert(clock_cast<gps_clock>(tt) == gt);
|
assert(clock_cast<gps_clock>(tt) == gt);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user