Merge "Fix indenting" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / math / compile-time-math.cpp
1 /*
2  * Copyright (c) 2017 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 // CLASS HEADER
19 #include <dali/public-api/math/compile-time-math.h>
20
21 // EXTERNAL INCLUDES
22 #include <type_traits>
23
24 namespace Dali
25 {
26
27 // verification for static asserts, these get removed from final binary by the linker
28 static_assert( Power<10,0>::value == 1, "" );
29 static_assert( Power<10,1>::value == 10, "" );
30 static_assert( Power<10,2>::value == 100, "" );
31 static_assert( Power<10,3>::value == 1000, "" );
32 static_assert( Power<4,4>::value == 256, "" );
33
34 static_assert( Log<0, 10>::value == 0, "" );
35 static_assert( Log<1, 10>::value == 0, "" );
36 static_assert( Log<2, 10>::value == 1, "" );
37 static_assert( Log<10, 10>::value == 1, "" );
38 static_assert( Log<100, 10>::value == 2, "" );
39 static_assert( Log<1000, 10>::value == 3, "" );
40
41 static_assert( Log<Power<10,0>::value, 10 >::value == 0, "" );
42 static_assert( Log<Power<2,0>::value, 2 >::value == 0, "" );
43 static_assert( Log<Power<10,2>::value, 10 >::value == 2, "" );
44 static_assert( Log<Power<2,2>::value, 2 >::value == 2, "" );
45
46 static_assert( Power<10, Log<10,10>::value >::value == 10, "" );
47 static_assert( Power<10, Log<100,10>::value >::value == 100, "" );
48
49 // TODO unfortunately cannot static assert floats so cannot test EPSILON here...
50
51 } // namespace Dali