Allow changing the format of StringMaker<float> and StringMaker<double>

This commit is contained in:
Will Pazner
2021-04-29 14:51:06 -07:00
parent 2dc5a5f402
commit 14d0d46cd1
3 changed files with 19 additions and 5 deletions

View File

@@ -127,6 +127,17 @@ inside the `StringMaker` specialization, like so:
This assertion will fail and print out the `testFloat1` and `testFloat2`
to 15 decimal places.
`StringMaker<float>` and `StringMaker<double>` default to using fixed output,
but can be set to use scientific notation by modifying the `format` static
variable:
```cpp
Catch::StringMaker<float>::format = std::scientific;
const float testFloat1 = 1e-5f;
const float testFloat2 = 1e-6f;
REQUIRE(testFloat1 == testFloat2);
```
---
[Home](Readme.md#top)