| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| /// Unit test cases for the math engine. |
| |
| #include <gtest/gtest.h> |
| |
| #include "src/calculator/engine/engine.h" |
| |
| namespace calculator_engine { |
| |
| /// The fixture for testing class the calculator engine. |
| class EngineUnitTest : public ::testing::Test { |
| protected: |
| EngineUnitTest() = default; |
| }; |
| |
| TEST_F(EngineUnitTest, Negate) { |
| double result = negate(3.5); |
| EXPECT_DOUBLE_EQ(-3.5, result); |
| } |
| |
| TEST_F(EngineUnitTest, Add) { |
| double result = add(3.5, 2.5); |
| EXPECT_DOUBLE_EQ(6., result); |
| } |
| |
| TEST_F(EngineUnitTest, Subtract) { |
| double result = subtract(3.5, 2.5); |
| EXPECT_DOUBLE_EQ(1., result); |
| } |
| |
| TEST_F(EngineUnitTest, Multiply) { |
| double result = multiply(3.5, 2.5); |
| EXPECT_DOUBLE_EQ(8.75, result); |
| } |
| |
| TEST_F(EngineUnitTest, Divide) { |
| double result = divide(3.5, 2.5); |
| EXPECT_DOUBLE_EQ(1.4, result); |
| } |
| |
| } // namespace calculator_engine |