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

Function TEST

Tests/Hash64_Test.cpp:32–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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