General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.0 KiB

  1. #include "test_scaffold.h"
  2. #include <random>
  3. #include <string>
  4. #include "gp/bloomfilter.hpp"
  5. typedef std::linear_congruential_engine<uint_fast64_t, 128273, 13, 2147483647> cheap_rand;
  6. typedef std::linear_congruential_engine<uint_fast64_t, 69857, 87541, 2147483647> cheap_rand_bis;
  7. struct bfilter_test : public test_scaffold {
  8. uint32_t seed;
  9. bfilter_test() {
  10. seed = std::random_device{}();
  11. name = __FILE__ ":1_seed";
  12. name += std::to_string(seed);
  13. }
  14. virtual int run() {
  15. cheap_rand setter(seed);
  16. cheap_rand getter(seed);
  17. gp::bloomfilter test_filter;
  18. for(int a = 0 ; a < 100; a++)
  19. {
  20. test_filter.set_hash(setter());
  21. }
  22. bool result = true;
  23. for(int a = 0 ; a < 100; a++)
  24. {
  25. result *= test_filter.test_hash(getter());
  26. }
  27. return !result;
  28. }
  29. };
  30. append_test dummy_r21fg6r43(new bfilter_test{});
  31. struct bfilter2_test : public test_scaffold {
  32. uint32_t seedA;
  33. uint32_t seedB;
  34. bfilter2_test() {
  35. seedA = std::random_device{}();
  36. seedB = std::random_device{}();
  37. name = __FILE__ ":2_seedA";
  38. name += std::to_string(seedA);
  39. name += "&seedB";
  40. name += std::to_string(seedB);
  41. }
  42. virtual int run() {
  43. cheap_rand setter(seedA);
  44. cheap_rand_bis getter(seedB);
  45. gp::bloomfilter test_filter;
  46. for(int a = 0 ; a < 10000; a++)
  47. {
  48. test_filter.set_hash(setter());
  49. }
  50. int interference = 0;
  51. for(int a = 0 ; a < 10000; a++)
  52. {
  53. interference += test_filter.test_hash(getter());
  54. }
  55. return interference >= 550;
  56. }
  57. };
  58. append_test dummy_r2gflu3(new bfilter2_test{});
  59. struct bfilter3_test : public test_scaffold {
  60. uint32_t seed;
  61. bfilter3_test() {
  62. seed = std::random_device{}();
  63. name = __FILE__ ":3_seed";
  64. name += std::to_string(seed);
  65. }
  66. virtual int run() {
  67. cheap_rand setter(seed);
  68. cheap_rand getter(seed);
  69. gp::bloomfilter<uint32_t, 19, true> test_filter;
  70. for(int a = 0 ; a < 1000; a++)
  71. {
  72. test_filter.set_hash(setter());
  73. }
  74. bool result = true;
  75. for(int a = 0 ; a < 1000; a++)
  76. {
  77. result *= test_filter.test_hash(getter());
  78. }
  79. return !result;
  80. }
  81. };
  82. append_test dummy_56489flu3(new bfilter3_test{});