Commit b06d3f53 authored by fbarchard@google.com's avatar fbarchard@google.com

Add more tests for hash

BUG=none
TEST=out\release\libyuv_unittest --gtest_filter=*Djb2*
Review URL: https://webrtc-codereview.appspot.com/1448004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@690 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 6a34ee20
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 688
Version: 689
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 688
#define LIBYUV_VERSION 689
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -70,6 +70,39 @@ TEST_F(libyuvTest, Djb2_Test) {
h2 = HashDjb2(src_b, kMaxTest, 1234);
EXPECT_NE(h1, h2);
// Make one byte different in middle. Expect hash is different.
memcpy(src_a, src_b, kMaxTest);
++src_b[kMaxTest / 2];
h1 = HashDjb2(src_a, kMaxTest, 5381);
h2 = HashDjb2(src_b, kMaxTest, 5381);
EXPECT_NE(h1, h2);
// Make first byte different. Expect hash is different.
memcpy(src_a, src_b, kMaxTest);
++src_b[0];
h1 = HashDjb2(src_a, kMaxTest, 5381);
h2 = HashDjb2(src_b, kMaxTest, 5381);
EXPECT_NE(h1, h2);
// Make last byte different. Expect hash is different.
memcpy(src_a, src_b, kMaxTest);
++src_b[kMaxTest - 1];
h1 = HashDjb2(src_a, kMaxTest, 5381);
h2 = HashDjb2(src_b, kMaxTest, 5381);
EXPECT_NE(h1, h2);
// Make a zeros. Test different lengths. Expect hash is different.
memset(src_a, 0, kMaxTest);
h1 = HashDjb2(src_a, kMaxTest, 5381);
h2 = HashDjb2(src_a, kMaxTest / 2, 5381);
EXPECT_NE(h1, h2);
// Make a zeros and seed of zero. Test different lengths. Expect hash is same.
memset(src_a, 0, kMaxTest);
h1 = HashDjb2(src_a, kMaxTest, 0);
h2 = HashDjb2(src_a, kMaxTest / 2, 0);
EXPECT_EQ(h1, h2);
free_aligned_buffer_64(src_a)
free_aligned_buffer_64(src_b)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment