Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-10-27 09:17:15 +0100
committerGitHub2019-10-27 09:17:15 +0100
commit9a558171d836cf7b292883b6f65bdd937c30cc76 (patch)
tree93b5af6d1abc58522f38b539e58d95ee0bbe24c1 /projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp
parentc5c688820c919e202304b885df1c5a920ff7eb4e (diff)
parent6a0822586382fcfa4bae4378b12656036850f959 (diff)
downloadcatch3-9a558171d836cf7b292883b6f65bdd937c30cc76.tar.gz
Merge pull request #1776 from mvd4/bugfix/enable-floating-point-ranges
Enable floating point ranges
Diffstat (limited to 'projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp')
-rw-r--r--projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp
index 076c91a9..9cbe8931 100644
--- a/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp
+++ b/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp
@@ -173,6 +173,58 @@ TEST_CASE("Generators internals", "[generators][internals]") {
REQUIRE_FALSE(gen.next());
}
}
+
+ SECTION("Floating Point") {
+ SECTION("Exact") {
+ const auto rangeStart = -1.;
+ const auto rangeEnd = 1.;
+ const auto step = .1;
+
+ auto gen = range(rangeStart, rangeEnd, step);
+ auto expected = rangeStart;
+ while( (rangeEnd - expected) > step ) {
+ INFO( "Current expected value is " << expected )
+ REQUIRE(gen.get() == Approx(expected));
+ REQUIRE(gen.next());
+
+ expected += step;
+ }
+ REQUIRE(gen.get() == Approx( rangeEnd ) );
+ REQUIRE_FALSE(gen.next());
+ }
+ SECTION("Slightly over end") {
+ const auto rangeStart = -1.;
+ const auto rangeEnd = 1.;
+ const auto step = .3;
+
+ auto gen = range(rangeStart, rangeEnd, step);
+ auto expected = rangeStart;
+ while( (rangeEnd - expected) > step ) {
+ INFO( "Current expected value is " << expected )
+ REQUIRE(gen.get() == Approx(expected));
+ REQUIRE(gen.next());
+
+ expected += step;
+ }
+ REQUIRE_FALSE(gen.next());
+ }
+ SECTION("Slightly under end") {
+ const auto rangeStart = -1.;
+ const auto rangeEnd = .9;
+ const auto step = .3;
+
+ auto gen = range(rangeStart, rangeEnd, step);
+ auto expected = rangeStart;
+ while( (rangeEnd - expected) > step ) {
+ INFO( "Current expected value is " << expected )
+ REQUIRE(gen.get() == Approx(expected));
+ REQUIRE(gen.next());
+
+ expected += step;
+ }
+ REQUIRE_FALSE(gen.next());
+ }
+ }
}
SECTION("Negative manual step") {
SECTION("Integer") {