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