libstdc++: Fix some tests that fail with -fexcess-precision=standard
libstdc++-v3/ChangeLog: * testsuite/20_util/duration/cons/2.cc: Use values that aren't affected by rounding. * testsuite/20_util/from_chars/5.cc: Cast arithmetic result to double before comparing for equality. * testsuite/20_util/from_chars/6.cc: Likewise. * testsuite/20_util/variant/86874.cc: Use values that aren't affected by rounding. * testsuite/25_algorithms/lower_bound/partitioned.cc: Compare to original value instead of to floating-point-literal. * testsuite/26_numerics/random/discrete_distribution/cons/range.cc: Cast arithmetic result to double before comparing for equality. * testsuite/26_numerics/random/piecewise_constant_distribution/cons/range.cc: Likewise. * testsuite/26_numerics/random/piecewise_linear_distribution/cons/range.cc: Likewise. * testsuite/26_numerics/valarray/transcend.cc (eq): Check that the absolute difference is less than 0.01 instead of comparing to two decimal places. * testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc: Cast arithmetic result to double before comparing for equality. * testsuite/27_io/basic_istream/extractors_arithmetic/char/09.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/01.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/09.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc: Likewise. * testsuite/ext/random/hoyt_distribution/cons/parms.cc: Likewise.
This commit is contained in:
parent
8cc8707446
commit
ae12aced97
16 changed files with 24 additions and 24 deletions
|
@ -97,7 +97,7 @@ test01()
|
|||
duration<int, std::micro> d1_copy(d1);
|
||||
VERIFY(d1.count() * 1000 == d1_copy.count());
|
||||
|
||||
duration<double, std::micro> d2(8.0);
|
||||
duration<double, std::micro> d2(85000);
|
||||
duration<double, std::milli> d2_copy(d2);
|
||||
VERIFY(d2.count() == d2_copy.count() * 1000.0);
|
||||
|
||||
|
@ -105,7 +105,7 @@ test01()
|
|||
duration<int_emulator, std::micro> d3_copy(d3);
|
||||
VERIFY(d3.count() * 1000 == d3_copy.count());
|
||||
|
||||
duration<dbl_emulator, std::micro> d4(5.0);
|
||||
duration<dbl_emulator, std::micro> d4(50000);
|
||||
duration<dbl_emulator, std::milli> d4_copy(d4);
|
||||
VERIFY(d4.count() == d4_copy.count() * dbl_emulator(1000.0));
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ test01()
|
|||
r = std::from_chars(s.data(), s.data() + s.length(), d, fmt);
|
||||
VERIFY( r.ec == std::errc::invalid_argument );
|
||||
VERIFY( r.ptr == s.data() );
|
||||
VERIFY( d == 3.2 );
|
||||
VERIFY( d == (double) 3.2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ test01()
|
|||
r = std::from_chars(s.data(), s.data() + s.length(), d, fmt);
|
||||
VERIFY( r.ec == std::errc::invalid_argument );
|
||||
VERIFY( r.ptr == s.data() );
|
||||
VERIFY( d == 3.2 );
|
||||
VERIFY( d == (double) 3.2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ test01()
|
|||
std::chars_format::scientific);
|
||||
VERIFY( r.ec == std::errc::invalid_argument );
|
||||
VERIFY( r.ptr == s.data() );
|
||||
VERIFY( d == 3.2 );
|
||||
VERIFY( d == (double) 3.2 );
|
||||
}
|
||||
|
||||
// patterns that are invalid without the final character
|
||||
|
@ -83,7 +83,7 @@ test01()
|
|||
r = std::from_chars(s.data(), s.data() + s.length() - 1, d, fmt);
|
||||
VERIFY( r.ec == std::errc::invalid_argument );
|
||||
VERIFY( r.ptr == s.data() );
|
||||
VERIFY( d == 3.2 );
|
||||
VERIFY( d == (double) 3.2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ test01()
|
|||
VERIFY( res.ptr == s.data() + s.length() );
|
||||
// std::from_chars should ignore the current rounding mode
|
||||
// and always round to nearest.
|
||||
VERIFY( d == 0.1 );
|
||||
VERIFY( d == (double) 0.1 );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ test02()
|
|||
void
|
||||
test03()
|
||||
{
|
||||
std::variant<double, int> v1{1}, v2{2.3};
|
||||
std::variant<double, int> v1{1}, v2{0.5};
|
||||
std::swap(v1, v2);
|
||||
VERIFY( std::get<double>(v1) == 2.3 );
|
||||
VERIFY( std::get<double>(v1) == 0.5 );
|
||||
VERIFY( std::get<int>(v2) == 1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -84,10 +84,10 @@ test02()
|
|||
|
||||
auto part3 = std::lower_bound(c.begin(), c.end(), Y{1.0});
|
||||
VERIFY( part3 != c.end() );
|
||||
VERIFY( part3->val == 1.2 );
|
||||
VERIFY( part3->val == seq[1].val );
|
||||
auto part4 = std::lower_bound(c.begin(), c.end(), Y{1.0}, std::less<Y>{});
|
||||
VERIFY( part4 != c.end() );
|
||||
VERIFY( part4->val == 1.2 );
|
||||
VERIFY( part4->val == seq[1].val );
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -33,8 +33,8 @@ test01()
|
|||
std::discrete_distribution<> u(wt.begin(), wt.end());
|
||||
std::vector<double> probablility = u.probabilities();
|
||||
VERIFY( probablility.size() == 5 );
|
||||
VERIFY( probablility[0] == 0.5 / 6.0 );
|
||||
VERIFY( probablility[2] == 2.5 / 6.0 );
|
||||
VERIFY( probablility[0] == double(0.5 / 6.0) );
|
||||
VERIFY( probablility[2] == double(2.5 / 6.0) );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -38,8 +38,8 @@ test01()
|
|||
VERIFY( interval[0] == 0.0 );
|
||||
VERIFY( interval[5] == 5.0 );
|
||||
VERIFY( density.size() == 5 );
|
||||
VERIFY( density[0] == 0.5 / 6.0 );
|
||||
VERIFY( density[2] == 2.5 / 6.0 );
|
||||
VERIFY( density[0] == double(0.5 / 6.0) );
|
||||
VERIFY( density[2] == double(2.5 / 6.0) );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -39,7 +39,7 @@ test01()
|
|||
VERIFY( interval[5] == 5.0 );
|
||||
VERIFY( density.size() == 6 );
|
||||
VERIFY( density[0] == 0.0 );
|
||||
VERIFY( density[4] == 3.5 / 8.5 );
|
||||
VERIFY( density[4] == double(3.5 / 8.5) );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
bool eq(double d, double e)
|
||||
{
|
||||
return (int)(d * 100) == (int)(e * 100);
|
||||
return std::abs(d - e) < 0.01;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -92,7 +92,7 @@ void test01() {
|
|||
is_03 >> ld1;
|
||||
VERIFY( ld1 == 66300.25 );
|
||||
is_03 >> d1;
|
||||
VERIFY( d1 == .315 );
|
||||
VERIFY( d1 == (double) .315 ); // N.B. cast removes excess precision
|
||||
is_03 >> f1;
|
||||
VERIFY( f1 == 1.5 );
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ void test09()
|
|||
(is>>std::ws) >> c;
|
||||
(is>>std::ws) >> f2;
|
||||
VERIFY( f1 == 2456 );
|
||||
VERIFY( f2 == 0.00567 );
|
||||
VERIFY( f2 == (double) 0.00567 ); // N.B. cast removes excess precision
|
||||
VERIFY( c == '-' );
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ void test10()
|
|||
VERIFY( f == 450.0 );
|
||||
is_04.ignore();
|
||||
is_04 >> f;
|
||||
VERIFY( f == 0.005 );
|
||||
VERIFY( f == (double) 0.005 ); // N.B. cast removes excess precision
|
||||
is_04 >> f;
|
||||
VERIFY( f == 6 );
|
||||
VERIFY( is_03.rdstate() == std::ios_base::eofbit );
|
||||
|
|
|
@ -90,7 +90,7 @@ void test01() {
|
|||
is_03 >> ld1;
|
||||
VERIFY( ld1 == 66300.25 );
|
||||
is_03 >> d1;
|
||||
VERIFY( d1 == .315 );
|
||||
VERIFY( d1 == (double) .315 ); // N.B. cast removes excess precision
|
||||
is_03 >> f1;
|
||||
VERIFY( f1 == 1.5 );
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void test09()
|
|||
(is >> std::ws) >> c;
|
||||
(is >> std::ws) >> f2;
|
||||
VERIFY( f1 == 2456 );
|
||||
VERIFY( f2 == 0.00567 );
|
||||
VERIFY( f2 == (double) 0.00567 ); // N.B. cast removes excess precision
|
||||
VERIFY( c == L'-' );
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ void test10()
|
|||
VERIFY( f == 450.0 );
|
||||
is_04.ignore();
|
||||
is_04 >> f;
|
||||
VERIFY( f == 0.005 );
|
||||
VERIFY( f == (double) 0.005 ); // N.B. cast removes excess precision
|
||||
is_04 >> f;
|
||||
VERIFY( f == 6 );
|
||||
VERIFY( is_03.rdstate() == std::ios_base::eofbit );
|
||||
|
|
|
@ -27,7 +27,7 @@ void
|
|||
test01()
|
||||
{
|
||||
__gnu_cxx::hoyt_distribution<> u(0.05, 3.0);
|
||||
VERIFY( u.q() == 0.05 );
|
||||
VERIFY( u.q() == (double) 0.05 );
|
||||
VERIFY( u.omega() == 3.0 );
|
||||
VERIFY( u.min() == 0.0 );
|
||||
typedef __gnu_cxx::hoyt_distribution<>::result_type result_type;
|
||||
|
|
Loading…
Add table
Reference in a new issue