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);
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));
}
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 );
}
}
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 );
}
}
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
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 );
}
}
}
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
}
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 );
}
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
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()
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()
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()
bool eq(double d, double e)
{
- return (int)(d * 100) == (int)(e * 100);
+ return std::abs(d - e) < 0.01;
}
void
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 );
(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 == '-' );
}
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 );
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 );
(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'-' );
}
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 );
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;