feat: first draft ceil

This commit is contained in:
Markus Hofbauer
2021-11-13 16:50:55 +01:00
committed by Mateusz Pusz
parent e82bfa23a5
commit b881b56480
3 changed files with 98 additions and 1 deletions
+42 -1
View File
@@ -133,7 +133,7 @@ TEST_CASE("floor functions", "[floor]")
SECTION ("floor 1.3 seconds with target unit second should be 1 second") {
REQUIRE(floor<si::second>(1.3_q_s) == 1_q_s);
}
SECTION ("floor -1.3 seconds with target unit second should be -1 second") {
SECTION ("floor -1.3 seconds with target unit second should be -2 seconds") {
REQUIRE(floor<si::second>(-1.3_q_s) == -2_q_s);
}
SECTION ("floor 1001. milliseconds with target unit second should be 1 second") {
@@ -150,6 +150,47 @@ TEST_CASE("floor functions", "[floor]")
}
}
TEST_CASE("ceil functions", "[ceil]")
{
SECTION ("ceil 1 second with target unit second should be 1 second") {
REQUIRE(ceil<si::second>(1_q_s) == 1_q_s);
}
SECTION ("ceil 1000 milliseconds with target unit second should be 1 second") {
REQUIRE(ceil<si::second>(1000_q_ms) == 1_q_s);
}
SECTION ("ceil 1001 milliseconds with target unit second should be 2 seconds") {
REQUIRE(ceil<si::second>(1001_q_ms) == 2_q_s);
}
SECTION ("ceil 1999 milliseconds with target unit second should be 2 seconds") {
REQUIRE(ceil<si::second>(1999_q_ms) == 2_q_s);
}
SECTION ("ceil -1000 milliseconds with target unit second should be -1 second") {
REQUIRE(ceil<si::second>(-1000_q_ms) == -1_q_s);
}
SECTION ("ceil -999 milliseconds with target unit second should be 0 seconds") {
REQUIRE(ceil<si::second>(-999_q_ms) == 0_q_s);
}
SECTION ("ceil 1.3 seconds with target unit second should be 2 seconds") {
REQUIRE(ceil<si::second>(1.3_q_s) == 2_q_s);
}
SECTION ("ceil -1.3 seconds with target unit second should be -1 second") {
REQUIRE(ceil<si::second>(-1.3_q_s) == -1_q_s);
}
SECTION ("ceil 1001. milliseconds with target unit second should be 2 seconds") {
REQUIRE(ceil<si::second>(1001._q_ms) == 2_q_s);
}
SECTION ("ceil 1999. milliseconds with target unit second should be 2 seconds") {
REQUIRE(ceil<si::second>(1999._q_ms) == 2_q_s);
}
// TODO does not work, probably due to a bug in fpow10() see #311
// SECTION ("ceil -1000. milliseconds with target unit second should be -1 second") {
// REQUIRE(ceil<si::second>(-1000._q_ms) == -1_q_s);
// }
SECTION ("ceil -999. milliseconds with target unit second should be 0 seconds") {
REQUIRE(ceil<si::second>(-999._q_ms) == 0_q_s);
}
}
TEMPLATE_TEST_CASE_SIG("pow<N>() implementation exponentiates values to power N", "[math][pow][exp]",
(std::intmax_t N, N), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25)
{