LCOV - code coverage report
Current view: top level - tests/arith - t_arith.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 11 11 100.0 %
Date: 2024-05-13 05:06:06 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*************************************************************************
       2             :  *
       3             :  *  Project
       4             :  *                        __  __ _______ _____  _  __
       5             :  *                       |  \/  |__   __|  __ \| |/ /
       6             :  *  ___  _ __   ___ _ __ | \  / |  | |  | |__) | ' /
       7             :  * / _ \| '_ \ / _ \ '_ \| |\/| |  | |  |  ___/|  <
       8             :  *| (_) | |_) |  __/ | | | |  | |  | |  | |    | . \
       9             :  * \___/| .__/ \___|_| |_|_|  |_|  |_|  |_|    |_|\_\
      10             :  *      | |
      11             :  *      |_|
      12             :  *
      13             :  *
      14             :  * Copyright (C) Akiel Aries, <akiel@akiel.org>, et al.
      15             :  *
      16             :  * This software is licensed as described in the file LICENSE, which
      17             :  * you should have received as part of this distribution. The terms
      18             :  * among other details are referenced in the official documentation
      19             :  * seen here : https://akielaries.github.io/openGPMP/ along with
      20             :  * important files seen in this project.
      21             :  *
      22             :  * You may opt to use, copy, modify, merge, publish, distribute
      23             :  * and/or sell copies of the Software, and permit persons to whom
      24             :  * the Software is furnished to do so, under the terms of the
      25             :  * LICENSE file. As this is an Open Source effort, all implementations
      26             :  * must be of the same methodology.
      27             :  *
      28             :  *
      29             :  *
      30             :  * This software is distributed on an AS IS basis, WITHOUT
      31             :  * WARRANTY OF ANY KIND, either express or implied.
      32             :  *
      33             :  ************************************************************************/
      34             : 
      35             : /*
      36             :  * Testing Arithmetic Operations
      37             :  */
      38             : #include <gtest/gtest.h>
      39             : #include <limits.h>
      40             : #include <openGPMP/arithmetic.hpp>
      41             : 
      42             : using ::testing::DoubleLE;
      43             : using ::testing::FloatLE;
      44             : using ::testing::InitGoogleTest;
      45             : 
      46             : /*
      47             : namespace {
      48             : gpmp::Arith ar;
      49             : 
      50             : 
      51             : // test case, test name
      52             : TEST(arith_test, add_positive) {
      53             :     EXPECT_EQ(46094, ar.add(93, 106, 3551, 42344));
      54             :     EXPECT_EQ(21, ar.add(10, 8, 3));
      55             :     EXPECT_EQ(6.85, ar.add(1.25, 1.85, 2.75, 1));
      56             : }
      57             : 
      58             : // multiplication (product) testing
      59             : TEST(arith_test, mult_positive) {
      60             :     EXPECT_EQ(240, ar.mult(10, 8, 3));
      61             :     EXPECT_EQ(6.359375, ar.mult(1.25, 1.85, 2.75, 1));
      62             : }
      63             : 
      64             : // subtraction
      65             : TEST(arith_test, sub_positive) {
      66             :     EXPECT_EQ(5, ar.sub(10, 8, 3));
      67             :     EXPECT_EQ(2.15, ar.sub(1.25, 1.85, 2.75));
      68             :     EXPECT_EQ(7, ar.sub(3, 3, 7));
      69             : }
      70             : } // namespace
      71             : */
      72             : namespace {
      73             : // gpmp::Arith<int> ar;
      74             : 
      75             : }
      76             : 
      77             : namespace {
      78             : gpmp::Basics ba;
      79             : 
      80             : // greatest power
      81           4 : TEST(BasicsTest, greatest_pow) {
      82           1 :     EXPECT_EQ(4, ba.greatest_power(10, 3));
      83           1 :     EXPECT_EQ(2, ba.greatest_power(7, 3));
      84           1 : }
      85             : 
      86             : // greatest common divisor
      87           4 : TEST(BasicsTest, greatest_common_divisor) {
      88           1 :     EXPECT_EQ(2, ba.op_gcd(2, 4));
      89           1 :     EXPECT_EQ(6, ba.op_gcd(2198466, 96096));
      90           1 :     EXPECT_EQ(11, ba.op_gcd(66, 11));
      91           1 :     EXPECT_EQ(8, ba.op_gcd(232, 96));
      92           1 :     EXPECT_EQ(10, ba.op_gcd(1703210, 20320));
      93           1 : }
      94             : } // namespace
      95             : /*
      96             : int main() {
      97             :     InitGoogleTest();
      98             : 
      99             :     return RUN_ALL_TESTS();
     100             : }
     101             : */

Generated by: LCOV version 1.14