Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
math_unittests.cc
Go to the documentation of this file.
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::kLog2E);
16 EXPECT_FLOAT_EQ(std::log10(math::kE), math::kLog10E);
17 EXPECT_FLOAT_EQ(std::log(2.0f), math::kLogE2);
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
#define TEST(S, s, D, expected)
constexpr float kLog2E
Definition math.h:15
constexpr float kSqrt2
Definition math.h:45
constexpr float kPiOver4
Definition math.h:33
constexpr float kPi
Definition math.h:27
constexpr float k2OverPi
Definition math.h:39
constexpr float kPiOver2
Definition math.h:30
constexpr float kLogE2
Definition math.h:21
constexpr float kE
Definition math.h:12
constexpr float k1OverSqrt2
Definition math.h:48
constexpr float kLog10E
Definition math.h:18
constexpr float k1OverPi
Definition math.h:36