1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <cmath>
6
7#include "flutter/fml/math.h"
8#include "gtest/gtest.h"
9
10namespace flutter {
11namespace testing {
12
13TEST(MathTest, Constants) {
14 // Don't use the constants in cmath as those aren't portable.
15 EXPECT_FLOAT_EQ(std::log2(math::kE), math::kLog2_E);
16 EXPECT_FLOAT_EQ(std::log10(math::kE), math::kLog10_E);
17 EXPECT_FLOAT_EQ(std::log(2.0f), math::klogE_2);
18 EXPECT_FLOAT_EQ(math::kPi / 2.0f, math::kPiOver2);
19 EXPECT_FLOAT_EQ(math::kPi / 4.0f, math::kPiOver4);
20 EXPECT_FLOAT_EQ(1.0f / math::kPi, math::k1OverPi);
21 EXPECT_FLOAT_EQ(2.0f / math::kPi, math::k2OverPi);
22 EXPECT_FLOAT_EQ(std::sqrt(2.0f), math::kSqrt2);
23 EXPECT_FLOAT_EQ(1.0f / std::sqrt(2.0f), math::k1OverSqrt2);
24}
25
26} // namespace testing
27} // namespace flutter
28

source code of flutter_engine/flutter/fml/math_unittests.cc