fnv_ut.cpp 825 B

1234567891011121314151617181920212223
  1. #include "fnv.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. Y_UNIT_TEST_SUITE(TFnvTest) {
  4. Y_UNIT_TEST(TestFnv32) {
  5. const auto h32 = ULL(2849763999);
  6. UNIT_ASSERT_EQUAL(FnvHash<ui32>("1234567", 7), h32);
  7. UNIT_ASSERT_EQUAL(FnvHash<ui32>(TStringBuf("1234567")), h32);
  8. UNIT_ASSERT_EQUAL(FnvHash<ui32>(nullptr, 0), FNV32INIT);
  9. UNIT_ASSERT_EQUAL(FnvHash<ui32>(TStringBuf()), FNV32INIT);
  10. }
  11. Y_UNIT_TEST(TestFnv64) {
  12. const auto h64 = ULL(2449551094593701855);
  13. UNIT_ASSERT_EQUAL(FnvHash<ui64>("1234567", 7), h64);
  14. UNIT_ASSERT_EQUAL(FnvHash<ui64>(TStringBuf("1234567")), h64);
  15. UNIT_ASSERT_EQUAL(FnvHash<ui64>(nullptr, 0), FNV64INIT);
  16. UNIT_ASSERT_EQUAL(FnvHash<ui64>(TStringBuf()), FNV64INIT);
  17. }
  18. } // Y_UNIT_TEST_SUITE(TFnvTest)