| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b3157a0 commit 0aa18e1
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,7 +124,7 @@ | |||
| 124 | 124 | ||
| 125 | 125 | #if GTEST_INTERNAL_HAS_STD_SPAN | |
| 126 | 126 | #include <span> // NOLINT | |
| 127 | - #endif // GTEST_INTERNAL_HAS_STD_SPAN | ||
| 127 | + #endif // GTEST_INTERNAL_HAS_STD_SPAN | ||
| 128 | 128 | ||
| 129 | 129 | namespace testing { | |
| 130 | 130 | ||
@@ -241,8 +241,8 @@ struct StreamPrinter { | |||
| 241 | 241 | // ADL (possibly involving implicit conversions). | |
| 242 | 242 | // (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name | |
| 243 | 243 | // lookup properly when we do it in the template parameter list.) | |
| 244 | - static auto PrintValue(const T& value, ::std::ostream* os) | ||
| 245 | - -> decltype((void)(*os << value)) { | ||
| 244 | + static auto PrintValue(const T& value, | ||
| 245 | + ::std::ostream* os) -> decltype((void)(*os << value)) { | ||
| 246 | 246 | // Call streaming operator found by ADL, possibly with implicit conversions | |
| 247 | 247 | // of the arguments. | |
| 248 | 248 | *os << value; | |
@@ -558,43 +558,50 @@ int AppropriateResolution(FloatType val) { | |||
| 558 | 558 | #endif | |
| 559 | 559 | if (val < 1000000) { | |
| 560 | 560 | FloatType mulfor6 = 1e10; | |
| 561 | - if (val >= 100000.0) { // 100,000 to 999,999 | ||
| 561 | + // Without these static casts, the template instantiation for float would | ||
| 562 | + // fail to compile when -Wdouble-promotion is enabled, as the arithmetic and | ||
| 563 | + // comparison logic would promote floats to doubles. | ||
| 564 | + if (val >= static_cast<FloatType>(100000.0)) { // 100,000 to 999,999 | ||
| 562 | 565 | mulfor6 = 1.0; | |
| 563 | - } else if (val >= 10000.0) { | ||
| 566 | + } else if (val >= static_cast<FloatType>(10000.0)) { | ||
| 564 | 567 | mulfor6 = 1e1; | |
| 565 | - } else if (val >= 1000.0) { | ||
| 568 | + } else if (val >= static_cast<FloatType>(1000.0)) { | ||
| 566 | 569 | mulfor6 = 1e2; | |
| 567 | - } else if (val >= 100.0) { | ||
| 570 | + } else if (val >= static_cast<FloatType>(100.0)) { | ||
| 568 | 571 | mulfor6 = 1e3; | |
| 569 | - } else if (val >= 10.0) { | ||
| 572 | + } else if (val >= static_cast<FloatType>(10.0)) { | ||
| 570 | 573 | mulfor6 = 1e4; | |
| 571 | - } else if (val >= 1.0) { | ||
| 574 | + } else if (val >= static_cast<FloatType>(1.0)) { | ||
| 572 | 575 | mulfor6 = 1e5; | |
| 573 | - } else if (val >= 0.1) { | ||
| 576 | + } else if (val >= static_cast<FloatType>(0.1)) { | ||
| 574 | 577 | mulfor6 = 1e6; | |
| 575 | - } else if (val >= 0.01) { | ||
| 578 | + } else if (val >= static_cast<FloatType>(0.01)) { | ||
| 576 | 579 | mulfor6 = 1e7; | |
| 577 | - } else if (val >= 0.001) { | ||
| 580 | + } else if (val >= static_cast<FloatType>(0.001)) { | ||
| 578 | 581 | mulfor6 = 1e8; | |
| 579 | - } else if (val >= 0.0001) { | ||
| 582 | + } else if (val >= static_cast<FloatType>(0.0001)) { | ||
| 580 | 583 | mulfor6 = 1e9; | |
| 581 | 584 | } | |
| 582 | - if (static_cast<FloatType>(static_cast<int32_t>(val * mulfor6 + 0.5)) / | ||
| 585 | + if (static_cast<FloatType>(static_cast<int32_t>( | ||
| 586 | + val * mulfor6 + (static_cast<FloatType>(0.5)))) / | ||
| 583 | 587 | mulfor6 == | |
| 584 | 588 | val) | |
| 585 | 589 | return 6; | |
| 586 | - } else if (val < 1e10) { | ||
| 587 | - FloatType divfor6 = 1.0; | ||
| 588 | - if (val >= 1e9) { // 1,000,000,000 to 9,999,999,999 | ||
| 590 | + } else if (val < static_cast<FloatType>(1e10)) { | ||
| 591 | + FloatType divfor6 = static_cast<FloatType>(1.0); | ||
| 592 | + if (val >= static_cast<FloatType>(1e9)) { // 1,000,000,000 to 9,999,999,999 | ||
| 589 | 593 | divfor6 = 10000; | |
| 590 | - } else if (val >= 1e8) { // 100,000,000 to 999,999,999 | ||
| 594 | + } else if (val >= | ||
| 595 | + static_cast<FloatType>(1e8)) { // 100,000,000 to 999,999,999 | ||
| 591 | 596 | divfor6 = 1000; | |
| 592 | - } else if (val >= 1e7) { // 10,000,000 to 99,999,999 | ||
| 597 | + } else if (val >= | ||
| 598 | + static_cast<FloatType>(1e7)) { // 10,000,000 to 99,999,999 | ||
| 593 | 599 | divfor6 = 100; | |
| 594 | - } else if (val >= 1e6) { // 1,000,000 to 9,999,999 | ||
| 600 | + } else if (val >= static_cast<FloatType>(1e6)) { // 1,000,000 to 9,999,999 | ||
| 595 | 601 | divfor6 = 10; | |
| 596 | 602 | } | |
| 597 | - if (static_cast<FloatType>(static_cast<int32_t>(val / divfor6 + 0.5)) * | ||
| 603 | + if (static_cast<FloatType>(static_cast<int32_t>( | ||
| 604 | + val / divfor6 + (static_cast<FloatType>(0.5)))) * | ||
| 598 | 605 | divfor6 == | |
| 599 | 606 | val) | |
| 600 | 607 | return 6; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -555,7 +555,7 @@ struct SuiteApiResolver : T { | |||
| 555 | 555 | // type_param: the name of the test's type parameter, or NULL if | |
| 556 | 556 | // this is not a typed or a type-parameterized test. | |
| 557 | 557 | // value_param: text representation of the test's value parameter, | |
| 558 | - // or NULL if this is not a type-parameterized test. | ||
| 558 | + // or NULL if this is not a value-parameterized test. | ||
| 559 | 559 | // code_location: code location where the test is defined | |
| 560 | 560 | // fixture_class_id: ID of the test fixture class | |
| 561 | 561 | // set_up_tc: pointer to the function that sets up the test suite | |
| Back | FazBrowse Home | New Git URL |
0 commit comments