Dali 3D User Interface Engine
utc-Dali-Hash.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 
18 #include <string>
19 #include <stdlib.h>
21 #include <dali-test-suite-utils.h>
22 
24 {
26 }
27 
29 {
31 }
32 
33 
34 int UtcDaliHash(void)
35 {
36  // To fully test the Hash distribution we need to use a tool like http://code.google.com/p/smhasher/
37  // DALi currently uses the hash for variable length strings which come from:
38  // shader vert+frag source, font family + style, image filename.
39  TestApplication application;
40 
41  tet_infoline("UtcDaliHash");
42 
43  const std::string testString1( "highp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
44  const std::string testString2( "lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
45 
46  DALI_TEST_CHECK( Dali::CalculateHash( testString1 ) != Dali::CalculateHash( testString2 ) );
47  DALI_TEST_CHECK( Dali::CalculateHash( testString1, testString2 ) != Dali::CalculateHash( testString2, testString1 ) );
48 
49  END_TEST;
50 }
51 
53 {
54  // negative test, check hash value == initial value
55  const std::string emptyString;
56 
57  DALI_TEST_CHECK( Dali::CalculateHash( emptyString ) != 0 );
58  DALI_TEST_CHECK( Dali::CalculateHash( emptyString, emptyString ) != 0 );
59 
60  END_TEST;
61 }
Dali Docs Home
Read more about Dali