2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
21 #include "dali-scene-loader/internal/hash.h"
22 #include <dali-test-suite-utils.h>
26 using namespace Dali::SceneLoader;
30 DALI_TEST_EQUAL(Hash(0).Add(true), 0);
31 DALI_TEST_EQUAL(Hash(0).Add(false), 1);
33 int32_t myInt32 = std::numeric_limits<int32_t>::min();
34 DALI_TEST_EQUAL(Hash(0).Add(myInt32), myInt32);
36 uint32_t myUint32 = std::numeric_limits<uint32_t>::max();
37 DALI_TEST_EQUAL(Hash(0).Add(myUint32), myUint32);
39 uint64_t myUint64 = std::numeric_limits<uint64_t>::max();
40 DALI_TEST_EQUAL(uint64_t(Hash(0).Add(myUint64)), myUint64);
42 constexpr uint32_t multiplier = 31;
43 uint64_t expected = 0;
45 for (auto i0 = reinterpret_cast<uint8_t const*>(&f), i1 = i0 + sizeof(f); i0 != i1; ++i0)
47 expected = expected * multiplier + *i0;
50 DALI_TEST_EQUAL(uint64_t(Hash(0).Add(f)), expected);