]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/hash/chi2_q_bit_string_set.cc
1 // Use smaller statistics when running on simulators, so it takes less time.
2 // For e.g. cris-elf, mipsisa32r2el-elf, powerpc-eabi and i386-linux-gnu,
3 // this test fails for SAMPLES=30000.
4 // { dg-options "-DSAMPLES=35000" { target simulator } }
5 // { dg-do run { target c++11 } }
7 // Copyright (C) 2010-2020 Free Software Foundation, Inc.
9 // This file is part of the GNU ISO C++ Library. This library is free
10 // software; you can redistribute it and/or modify it under the
11 // terms of the GNU General Public License as published by the
12 // Free Software Foundation; either version 3, or (at your option)
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
24 #include "chi2_quality.h"
26 // Tests chi^2 for a set of strings that all consist of '1' and '0'.
30 const unsigned long N
= SAMPLES
;
31 const unsigned long k
= N
/100;
32 std::vector
<std::string
> set
;
34 for (unsigned long i
= 0; i
< N
; ++i
)
37 for (unsigned int j
= 0; j
< sizeof(unsigned long) * 8; ++j
)
39 const bool bit
= (1UL << j
) & i
;
40 s
.push_back(bit
? '1' : '0');
45 double chi2
= chi2_hash(set
, k
);
46 VERIFY( chi2
< k
*1.1 );
52 test_bit_string_set();