locale_facets.tcc (collate::do_hash): Fix.

2002-02-11  Aaron W LaFramboise  <AWLaFramboise@aol.com>

	* include/bits/locale_facets.tcc (collate::do_hash): Fix.
	* testsuite/22_locale/collate_members_char.cc (test03): New test.
	* testsuite/22_locale/collate_members_wchar_t.cc (test03): Same.

From-SVN: r49682
This commit is contained in:
Aaron W. LaFramboise 2002-02-11 18:56:24 +00:00 committed by Benjamin Kosnik
parent df61a3d22a
commit 4e2f8bcf6f
4 changed files with 37 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2002-02-11 Aaron W LaFramboise <AWLaFramboise@aol.com>
* include/bits/locale_facets.tcc (collate::do_hash): Fix.
* testsuite/22_locale/collate_members_char.cc (test03): New test.
* testsuite/22_locale/collate_members_wchar_t.cc (test03): Same.
2002-02-10 Phil Edwards <pme@gcc.gnu.org>
* include/bits/stl_algo.h (transform (both signatures), generate_n):

View File

@ -1855,7 +1855,7 @@ namespace std
unsigned long __val = 0;
for (; __lo < __hi; ++__lo)
__val = *__lo + ((__val << 7) |
(__val >> (numeric_limits<unsigned long>::digits - 1)));
(__val >> (numeric_limits<unsigned long>::digits - 7)));
return static_cast<long>(__val);
}

View File

@ -147,12 +147,24 @@ void test02()
#endif
}
void test03()
{
bool test = true;
std::string str1("fffff");
std::string str2("ffffffffffff");
const std::locale cloc = std::locale::classic();
const std::collate<char> &col = std::use_facet<std::collate<char> >(cloc);
long l1 = col.hash(str1.c_str(), str1.c_str() + str1.size());
long l2 = col.hash(str2.c_str(), str2.c_str() + str2.size());
VERIFY( l1 != l2 );
}
int main()
{
test01();
test02();
test03();
return 0;
}

View File

@ -146,6 +146,20 @@ void test02()
}
#endif
}
void test03()
{
bool test = true;
std::wstring str1(L"fffff");
std::wstring str2(L"ffffffffffff");
const std::locale cloc = std::locale::classic();
const std::collate<wchar_t> &col = std::use_facet<std::collate<wchar_t> >(cloc);
long l1 = col.hash(str1.c_str(), str1.c_str() + str1.size());
long l2 = col.hash(str2.c_str(), str2.c_str() + str2.size());
VERIFY( l1 != l2 );
}
#endif
int main()
@ -153,10 +167,7 @@ int main()
#if _GLIBCPP_USE_WCHAR_T
test01();
test02();
test03();
#endif
return 0;
}