MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / TEST

Function TEST

Tests/Hash64_Test.cpp:33–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#include "Engine/Hash64.h"
32
33NATRON_NAMESPACE_USING
34
35TEST(Hash64,
36 GeneralTest)
37{
38 Hash64 hash1;
39
40 ASSERT_FALSE( hash1.valid() ) << "A fresh hash is not valid.";
41
42 hash1.computeHash();
43 ASSERT_FALSE( hash1.valid() ) << "Compute on an empty hash doesn't make it valid";
44
45 hash1.append<int>(3);
46 ASSERT_FALSE( hash1.valid() ) << "You need to call compute to make the hash valid";
47
48 hash1.computeHash();
49 ASSERT_TRUE( hash1.valid() );
50
51 hash1.reset();
52 ASSERT_FALSE( hash1.valid() );
53
54 srand(2000);
55 // coverity[dont_call]
56 int hash1ElementCount = rand() % 100 + 80;
57 std::vector<int> hash1Elements;
58 for (int i = 0; i < hash1ElementCount; ++i) {
59 // coverity[dont_call]
60 int v = rand();
61 hash1Elements.push_back(v);
62 hash1.append<int>(v);
63 }
64
65 hash1.computeHash();
66 ASSERT_TRUE( hash1.valid() );
67
68 Hash64 hash2;
69 for (int i = 0; i < hash1ElementCount; ++i) {
70 hash2.append<int>(hash1Elements[i]);
71 }
72 hash2.computeHash();
73 ASSERT_TRUE( hash2.valid() );
74
75 EXPECT_EQ( hash1.value(), hash2.value() ) << "Hashs with same elements should be equal.";
76 EXPECT_EQ(hash1, hash2);
77
78 hash2.reset();
79 ASSERT_FALSE( hash2.valid() );
80
81 // coverity[dont_call]
82 int hash2ElementCount = hash1ElementCount + (rand() % 10 + 1);
83 for (int i = 0; i < hash2ElementCount; ++i) {
84 // coverity[dont_call]
85 hash2.append<int>( rand() );
86 }
87 hash2.computeHash();
88 ASSERT_TRUE( hash2.valid() );
89
90 EXPECT_NE( hash1.value(), hash2.value() );

Callers

nothing calls this directly

Calls 4

computeHashMethod · 0.45
resetMethod · 0.45
push_backMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected