sfh_ut.cpp 862 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "sfh.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. #include <util/stream/output.h>
  4. class TSfhTest: public TTestBase {
  5. UNIT_TEST_SUITE(TSfhTest);
  6. UNIT_TEST(TestSfh)
  7. UNIT_TEST_SUITE_END();
  8. private:
  9. inline void TestSfh() {
  10. ui8 buf[256];
  11. for (size_t i = 0; i < 256; ++i) {
  12. buf[i] = i;
  13. }
  14. Test(buf, 256, 3840866583UL);
  15. Test(buf, 255, 325350515UL);
  16. Test(buf, 254, 2920741773UL);
  17. Test(buf, 253, 3586628615UL);
  18. }
  19. private:
  20. inline void Test(const void* data, size_t len, ui32 expected) {
  21. const ui32 res = SuperFastHash(data, len);
  22. try {
  23. UNIT_ASSERT_EQUAL(res, expected);
  24. } catch (...) {
  25. Cerr << res << ", " << expected << Endl;
  26. throw;
  27. }
  28. }
  29. };
  30. UNIT_TEST_SUITE_REGISTRATION(TSfhTest);