2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 #include <dali/public-api/math/compile-time-math.h>
21 #include <dali/public-api/math/compile-time-assert.h>
28 // verification for static asserts, these get removed from final binary by the linker
29 const unsigned int value0 = Power<10,0>::value;
30 DALI_COMPILE_TIME_ASSERT( value0 == 1 ); // cannot have template with , inside macro... macros suck
31 const unsigned int value1 = Power<10,1>::value;
32 DALI_COMPILE_TIME_ASSERT( value1 == 10 );
33 const unsigned int value2 = Power<10,2>::value;
34 DALI_COMPILE_TIME_ASSERT( value2 == 100 );
35 const unsigned int value3 = Power<10,3>::value;
36 DALI_COMPILE_TIME_ASSERT( value3 == 1000 );
37 const unsigned int value4 = Power<4,4>::value;
38 DALI_COMPILE_TIME_ASSERT( value4 == 256 );
40 const unsigned int log0 = Log<0, 10>::value;
41 DALI_COMPILE_TIME_ASSERT( log0 == 0 );
42 const unsigned int log1 = Log<1, 10>::value;
43 DALI_COMPILE_TIME_ASSERT( log1 == 0 );
44 const unsigned int log2 = Log<2, 10>::value;
45 DALI_COMPILE_TIME_ASSERT( log2 == 1 );
46 const unsigned int log3 = Log<10, 10>::value;
47 DALI_COMPILE_TIME_ASSERT( log3 == 1 );
48 const unsigned int log4 = Log<100, 10>::value;
49 DALI_COMPILE_TIME_ASSERT( log4 == 2 );
50 const unsigned int log5 = Log<1000, 10>::value;
51 DALI_COMPILE_TIME_ASSERT( log5 == 3 );
53 const unsigned int logpow0 = Log<Power<10,0>::value, 10 >::value;
54 DALI_COMPILE_TIME_ASSERT( logpow0 == 0 );
55 const unsigned int logpow1 = Log<Power<2,0>::value, 2 >::value;
56 DALI_COMPILE_TIME_ASSERT( logpow1 == 0 );
57 const unsigned int logpow2 = Log<Power<10,2>::value, 10 >::value;
58 DALI_COMPILE_TIME_ASSERT( logpow2 == 2 );
59 const unsigned int logpow3 = Log<Power<2,2>::value, 2 >::value;
60 DALI_COMPILE_TIME_ASSERT( logpow3 == 2 );
62 const unsigned int powlog0 = Power<10, Log<10,10>::value >::value;
63 DALI_COMPILE_TIME_ASSERT( powlog0 == 10 );
64 const unsigned int powlog1 = Power<10, Log<100,10>::value >::value;
65 DALI_COMPILE_TIME_ASSERT( powlog1 == 100 );
67 // TODO unfortunately cannot static assert floats so cannot test EPSILON here...