mirror of git://gcc.gnu.org/git/gcc.git
libstdc++: Fix VERIFY(idx = 1) bugs in tests
These should be checking for equality, not performing assignments. The tests for from_range on associative containers were actually checking the wrong thing, but the bug in the is_equal function was making the incorrect checks pass anyway, because all the values being used were non-zero, so the result of lhs.id = rhs.id was true, but would have been false if lhs.id == rhs.id had been used as intended. libstdc++-v3/ChangeLog: * testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc: Fix assignment used instead of equality comparison. * testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc: Likewise. * testsuite/23_containers/map/cons/from_range.cc: Fix is_equal function and expected value of comparison functions after construction. * testsuite/23_containers/multimap/cons/from_range.cc: Likewise. * testsuite/23_containers/multiset/cons/from_range.cc: Likewise. * testsuite/23_containers/set/cons/from_range.cc: Likewise. * testsuite/23_containers/unordered_map/cons/from_range.cc: Fix is_equal functions. * testsuite/23_containers/unordered_multimap/cons/from_range.cc: Likewise. * testsuite/23_containers/unordered_multiset/cons/from_range.cc: Likewise. * testsuite/23_containers/unordered_set/cons/from_range.cc: Likewise. * testsuite/25_algorithms/minmax/constrained.cc: Fix assignment used instead of equality comparison. * testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc: Likewise.
This commit is contained in:
parent
10bb371eee
commit
f6c71c2079
|
|
@ -86,7 +86,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( i1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( l1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( ll1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( ul1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( ull1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( i1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( l1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( ll1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( ul1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ test01()
|
|||
}
|
||||
VERIFY( test );
|
||||
VERIFY( ull1 == 7 );
|
||||
VERIFY( idx1 = 1 );
|
||||
VERIFY( idx1 == 1 );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ constexpr bool is_equal(std::less<T>, std::less<U>)
|
|||
{ return true; }
|
||||
|
||||
constexpr bool is_equal(StateCmp lhs, StateCmp rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
constexpr auto get0 = [](auto const& t) {
|
||||
using std::get;
|
||||
|
|
@ -103,12 +103,12 @@ do_test(Alloc alloc, Cmp cmp)
|
|||
std::map<K, V, Cmp, Alloc> m4(std::from_range, Range(a, a+4), cmp);
|
||||
VERIFY( eq(m4, {a, 4}) );
|
||||
VERIFY( m4.get_allocator() == Alloc() );
|
||||
VERIFY( is_equal(m4.key_comp(), Cmp()) );
|
||||
VERIFY( is_equal(m4.key_comp(), cmp) );
|
||||
|
||||
std::map<K, V, Cmp, Alloc> m9(std::from_range, Range(a, a+9), alloc);
|
||||
VERIFY( eq(m9, {a, 9}) );
|
||||
VERIFY( m9.get_allocator() == alloc );
|
||||
VERIFY( is_equal(m9.key_comp(), cmp) );
|
||||
VERIFY( is_equal(m9.key_comp(), Cmp()) );
|
||||
|
||||
std::map<K, V, Cmp, Alloc> mr(std::from_range, Range(a, a+14), cmp, alloc);
|
||||
VERIFY( eq(mr, {a, 9}) );
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ constexpr bool is_equal(std::less<T>, std::less<U>)
|
|||
{ return true; }
|
||||
|
||||
constexpr bool is_equal(StateCmp lhs, StateCmp rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
constexpr auto get0 = [](auto const& t) {
|
||||
using std::get;
|
||||
|
|
@ -103,12 +103,12 @@ do_test(Alloc alloc, Cmp cmp)
|
|||
std::multimap<K, V, Cmp, Alloc> m4(std::from_range, Range(a, a+4), cmp);
|
||||
VERIFY( eq(m4, {a, 4}) );
|
||||
VERIFY( m4.get_allocator() == Alloc() );
|
||||
VERIFY( is_equal(m4.key_comp(), Cmp()) );
|
||||
VERIFY( is_equal(m4.key_comp(), cmp) );
|
||||
|
||||
std::multimap<K, V, Cmp, Alloc> m9(std::from_range, Range(a, a+9), alloc);
|
||||
VERIFY( eq(m9, {a, 9}) );
|
||||
VERIFY( m9.get_allocator() == alloc );
|
||||
VERIFY( is_equal(m9.key_comp(), cmp) );
|
||||
VERIFY( is_equal(m9.key_comp(), Cmp()) );
|
||||
|
||||
std::multimap<K, V, Cmp, Alloc> mr(std::from_range, Range(a, a+14), cmp, alloc);
|
||||
VERIFY( eq(mr, {a, 14}) );
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ constexpr bool is_equal(std::less<T>, std::less<U>)
|
|||
{ return true; }
|
||||
|
||||
constexpr bool is_equal(StateCmp lhs, StateCmp rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
template<typename Range, typename Alloc, typename Cmp>
|
||||
constexpr void
|
||||
|
|
@ -82,12 +82,12 @@ do_test(Alloc alloc, Cmp cmp)
|
|||
std::set<V, Cmp, Alloc> s4(std::from_range, Range(a, a+4), cmp);
|
||||
VERIFY( eq(s4, {a, 4}) );
|
||||
VERIFY( s4.get_allocator() == Alloc() );
|
||||
VERIFY( is_equal(s4.key_comp(), Cmp()) );
|
||||
VERIFY( is_equal(s4.key_comp(), cmp) );
|
||||
|
||||
std::set<V, Cmp, Alloc> s9(std::from_range, Range(a, a+9), alloc);
|
||||
VERIFY( eq(s9, {a, 9}) );
|
||||
VERIFY( s9.get_allocator() == alloc );
|
||||
VERIFY( is_equal(s9.key_comp(), cmp) );
|
||||
VERIFY( is_equal(s9.key_comp(), Cmp()) );
|
||||
|
||||
std::set<V, Cmp, Alloc> sr(std::from_range, Range(a, a+14), cmp, alloc);
|
||||
VERIFY( eq(sr, {a, 9}) );
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ constexpr bool is_equal(std::less<T>, std::less<U>)
|
|||
{ return true; }
|
||||
|
||||
constexpr bool is_equal(StateCmp lhs, StateCmp rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
template<typename Range, typename Alloc, typename Cmp>
|
||||
constexpr void
|
||||
|
|
@ -81,12 +81,12 @@ do_test(Alloc alloc, Cmp cmp)
|
|||
std::set<V, Cmp, Alloc> s4(std::from_range, Range(a, a+4), cmp);
|
||||
VERIFY( eq(s4, {a, 4}) );
|
||||
VERIFY( s4.get_allocator() == Alloc() );
|
||||
VERIFY( is_equal(s4.key_comp(), Cmp()) );
|
||||
VERIFY( is_equal(s4.key_comp(), cmp) );
|
||||
|
||||
std::set<V, Cmp, Alloc> s9(std::from_range, Range(a, a+9), alloc);
|
||||
VERIFY( eq(s9, {a, 9}) );
|
||||
VERIFY( s9.get_allocator() == alloc );
|
||||
VERIFY( is_equal(s9.key_comp(), cmp) );
|
||||
VERIFY( is_equal(s9.key_comp(), Cmp()) );
|
||||
|
||||
std::set<V, Cmp, Alloc> sr(std::from_range, Range(a, a+14), cmp, alloc);
|
||||
VERIFY( eq(sr, {a, 9}) );
|
||||
|
|
|
|||
|
|
@ -100,10 +100,10 @@ constexpr bool is_equal(std::equal_to<T>, std::equal_to<U>)
|
|||
{ return true; }
|
||||
|
||||
constexpr bool is_equal(StateHash lhs, StateHash rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
constexpr bool is_equal(StateEq lhs, StateEq rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
template<typename Range, typename Alloc, typename Hash, typename Equal>
|
||||
constexpr void
|
||||
|
|
|
|||
|
|
@ -114,10 +114,10 @@ constexpr bool is_equal(std::equal_to<T>, std::equal_to<U>)
|
|||
{ return true; }
|
||||
|
||||
constexpr bool is_equal(StateHash lhs, StateHash rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
constexpr bool is_equal(StateEq lhs, StateEq rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
template<typename Range, typename Alloc, typename Hash, typename Equal>
|
||||
constexpr void
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ constexpr bool is_equal(std::equal_to<T>, std::equal_to<U>)
|
|||
{ return true; }
|
||||
|
||||
constexpr bool is_equal(StateHash lhs, StateHash rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
|
||||
constexpr bool is_equal(StateEq lhs, StateEq rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
template<typename Range, typename Alloc, typename Hash, typename Equal>
|
||||
constexpr void
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ constexpr bool is_equal(std::equal_to<T>, std::equal_to<U>)
|
|||
{ return true; }
|
||||
|
||||
constexpr bool is_equal(StateHash lhs, StateHash rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
|
||||
constexpr bool is_equal(StateEq lhs, StateEq rhs)
|
||||
{ return lhs.state = rhs.state; }
|
||||
{ return lhs.state == rhs.state; }
|
||||
|
||||
template<typename Range, typename Alloc, typename Hash, typename Equal>
|
||||
constexpr void
|
||||
|
|
|
|||
|
|
@ -101,26 +101,26 @@ test04()
|
|||
|
||||
auto p = ranges::minmax({1,2}, counted_less{});
|
||||
VERIFY( counter == 1 );
|
||||
VERIFY( p.min = 1 );
|
||||
VERIFY( p.max = 2 );
|
||||
VERIFY( p.min == 1 );
|
||||
VERIFY( p.max == 2 );
|
||||
|
||||
counter = 0;
|
||||
p = ranges::minmax({1,2,3}, counted_less{});
|
||||
VERIFY( counter == 3 );
|
||||
VERIFY( p.min = 1 );
|
||||
VERIFY( p.max = 3 );
|
||||
VERIFY( p.min == 1 );
|
||||
VERIFY( p.max == 3 );
|
||||
|
||||
counter = 0;
|
||||
p = ranges::minmax({1,2,3,4,5,6,7,8,9,10}, counted_less{});
|
||||
VERIFY( counter <= 15 );
|
||||
VERIFY( p.min = 1 );
|
||||
VERIFY( p.max = 10 );
|
||||
VERIFY( p.min == 1 );
|
||||
VERIFY( p.max == 10 );
|
||||
|
||||
counter = 0;
|
||||
p = ranges::minmax({10,9,8,7,6,5,4,3,2,1}, counted_less{});
|
||||
VERIFY( counter <= 15 );
|
||||
VERIFY( p.min = 1 );
|
||||
VERIFY( p.max = 10 );
|
||||
VERIFY( p.min == 1 );
|
||||
VERIFY( p.max == 10 );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ void test01()
|
|||
tm time1;
|
||||
iss >> get_time(&time1, L"%H:%M:%S %Y");
|
||||
VERIFY( static_cast<bool>(iss) );
|
||||
VERIFY(time1.tm_hour = 12);
|
||||
VERIFY(time1.tm_min = 1);
|
||||
VERIFY(time1.tm_hour == 12);
|
||||
VERIFY(time1.tm_min == 1);
|
||||
VERIFY(time1.tm_sec == 30);
|
||||
VERIFY(time1.tm_year == 71);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue