From 19fd98331d1dac25f615416e3e4ef5e2552860a8 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 1 Nov 2010 00:08:58 +0000 Subject: [PATCH] dr1325-2.cc: Fix typo. 2010-10-31 Paolo Carlini * testsuite/23_containers/bitset/cons/dr1325-2.cc: Fix typo. * testsuite/20_util/hash/quality.cc: Avoid -Wall warnings. * testsuite/20_util/hash/chi2_quality.cc: Likewise. From-SVN: r166114 --- libstdc++-v3/ChangeLog | 6 ++++ .../testsuite/20_util/hash/chi2_quality.cc | 10 +++---- .../testsuite/20_util/hash/quality.cc | 30 +++++++++---------- .../23_containers/bitset/cons/dr1325-2.cc | 2 +- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 88918491263..793b8dcb103 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2010-10-31 Paolo Carlini + + * testsuite/23_containers/bitset/cons/dr1325-2.cc: Fix typo. + * testsuite/20_util/hash/quality.cc: Avoid -Wall warnings. + * testsuite/20_util/hash/chi2_quality.cc: Likewise. + 2010-10-29 Paolo Carlini * include/bits/stl_function.h (_Select1st<>::operator()): Add diff --git a/libstdc++-v3/testsuite/20_util/hash/chi2_quality.cc b/libstdc++-v3/testsuite/20_util/hash/chi2_quality.cc index 4c2f09e3ce7..a105f4b45d0 100644 --- a/libstdc++-v3/testsuite/20_util/hash/chi2_quality.cc +++ b/libstdc++-v3/testsuite/20_util/hash/chi2_quality.cc @@ -91,10 +91,8 @@ test_uniform_random() while (set.size() < N) { s.clear(); - for (int i = 0; i < len; ++i) - { - s.push_back(rand() % 128); - } + for (unsigned int i = 0; i < len; ++i) + s.push_back(rand() % 128); set.insert(s); } @@ -122,7 +120,7 @@ test_bit_flip_set() while (set.size() < N) { std::string s(base, base+len); - for (int i = 0; i < bits_to_flip; ++i) + for (unsigned int i = 0; i < bits_to_flip; ++i) { int bit = rand() % bitlen; s[bit/8] ^= (1 << (bit%8)); @@ -168,7 +166,7 @@ test_bit_string_set() for (unsigned long i = 0; i < N; ++i) { s.clear(); - for (int j = 0; j < sizeof(unsigned long) * 8; ++j) + for (unsigned int j = 0; j < sizeof(unsigned long) * 8; ++j) { const bool bit = (1UL << j) & i; s.push_back(bit ? '1' : '0'); diff --git a/libstdc++-v3/testsuite/20_util/hash/quality.cc b/libstdc++-v3/testsuite/20_util/hash/quality.cc index 3e3951f00ed..8a6edac1687 100644 --- a/libstdc++-v3/testsuite/20_util/hash/quality.cc +++ b/libstdc++-v3/testsuite/20_util/hash/quality.cc @@ -37,12 +37,12 @@ using namespace std; #define STRSIZE 42 #endif -const int num_quality_tests = NTESTS; -const int num_strings_for_quality_tests = NSTRINGS; -const int string_size = STRSIZE; +const unsigned int num_quality_tests = NTESTS; +const unsigned int num_strings_for_quality_tests = NSTRINGS; +const unsigned int string_size = STRSIZE; vector -random_strings(int n, int len) +random_strings(unsigned int n, unsigned int len) { string s(len, '\0'); unordered_set result_set; @@ -57,10 +57,10 @@ random_strings(int n, int len) } double -score_from_varying_position(string s, int index) +score_from_varying_position(string s, unsigned int index) { bool test __attribute__((unused)) = true; - int bits_in_hash_code = sizeof(size_t) * 8; + unsigned int bits_in_hash_code = sizeof(size_t) * 8; // We'll iterate through all 256 vals for s[index], leaving the rest // of s fixed. Then, for example, out of the 128 times that @@ -71,9 +71,9 @@ score_from_varying_position(string s, int index) // count the number of times each output position (of which there are // bits_in_hash_code) is 1 for each bit position within s[index] (of // which there are 8) and value of that bit (of which there are 2). - const int jj = 2; - const int kk = jj * bits_in_hash_code; - const int array_size = 8 * kk; + const unsigned int jj = 2; + const unsigned int kk = jj * bits_in_hash_code; + const unsigned int array_size = 8 * kk; vector ones(array_size, 0); for (int i = 0; i < 256; i++) @@ -99,7 +99,7 @@ score_from_varying_position(string s, int index) int good = 0, bad = 0; for (int bit = 0; bit <= 1; bit++) { - for (int j = 0; j < bits_in_hash_code; j++) + for (unsigned int j = 0; j < bits_in_hash_code; j++) { for (int bitpos = 0; bitpos < 8; bitpos++) { @@ -121,21 +121,21 @@ score_from_varying_position(string s, int index) } double -score_from_varying_position(const vector& v, int index) +score_from_varying_position(const vector& v, unsigned int index) { double score = 0; - for (int i = 0; i < v.size(); i++) + for (unsigned int i = 0; i < v.size(); i++) score += score_from_varying_position(v[i], index); return score / v.size(); } double -quality_test(int num_strings, int string_size) +quality_test(unsigned int num_strings, unsigned int string_size) { // Construct random strings. vector v = random_strings(num_strings, string_size); double sum_of_scores = 0; - for (int i = 0; i < string_size; i++) + for (unsigned int i = 0; i < string_size; i++) sum_of_scores += score_from_varying_position(v, i); // A good hash function should have a score very close to 1, and a bad @@ -149,7 +149,7 @@ quality_test() bool test __attribute__((unused)) = true; srand(137); double sum_of_scores = 0; - for (int i = 0; i < num_quality_tests; i++) + for (unsigned int i = 0; i < num_quality_tests; i++) { double score = quality_test(num_strings_for_quality_tests, string_size); diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc index e58565136da..e261ce5e6e0 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc +++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc @@ -45,7 +45,7 @@ void test01() VERIFY( bitset<4>(s1, 4) == test01_ref<4>(s1, 4) ); const char s2[3] = { '1', '1', '0' }; - VERIFY( bitset<6>(s1, 3) == test01_ref<6>(s1, 3) ); + VERIFY( bitset<6>(s2, 3) == test01_ref<6>(s2, 3) ); const char* s3 = "1110110"; VERIFY( bitset<7>(s3) == test01_ref<7>(s3) );