///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2023- Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // #include "gtest/gtest.h" #include "RimWellLogCalculatedCurve.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST( RimWellLogCalculatedCurve, unionDepthValuesFromVectors_singleValuesInDepthVectors ) { // Depth vectors without duplicates const std::vector depthValues1 = { 1.0, 2.0, 3.0, 4.0 }; const std::vector depthValues2 = { 2.0, 3.0, 4.0, 5.0 }; const double threshold = 0.1; // Expected duplicate occurrence of common depth values const std::vector expectedUnionDepthValues = { 1.0, 2.0, 3.0, 4.0, 5.0 }; // Call the function under test const std::vector unionDepthValues = RimWellLogCalculatedCurve::unionDepthValuesFromVectors( depthValues1, depthValues2, threshold ); ASSERT_EQ( unionDepthValues, expectedUnionDepthValues ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST( RimWellLogCalculatedCurve, unionDepthValuesFromVectors_duplicateValuesInDepthVectors ) { // Depth vectors with duplicates const std::vector depthValues1 = { 0.0, 0.5, 0.5, 1.0, 1.0, 1.5, 1.5 }; const std::vector depthValues2 = { 1.5, 1.5, 2.0, 2.0, 2.5, 2.5, 3.0 }; const double threshold = 0.1; // Expected no duplicate occurrences of depth values const std::vector expectedUnionDepthValues = { 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0 }; // Call the function under test const std::vector unionDepthValues = RimWellLogCalculatedCurve::unionDepthValuesFromVectors( depthValues1, depthValues2, threshold ); ASSERT_EQ( unionDepthValues, expectedUnionDepthValues ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST( RimWellLogCalculatedCurve, unionDepthValuesFromVectors_thresholdVerification ) { // Depth vectors with duplicates const std::vector depthValues1 = { 0.0, 0.5, 1.0, 1.5 }; const std::vector depthValues2 = { 2.0, 2.5, 3.0, 4.0 }; const double threshold = 0.6; // Expected every second value to be skipped due to threshold const std::vector expectedUnionDepthValues = { 0.0, 1.0, 2.0, 3.0, 4.0 }; // Call the function under test const std::vector unionDepthValues = RimWellLogCalculatedCurve::unionDepthValuesFromVectors( depthValues1, depthValues2, threshold ); ASSERT_EQ( unionDepthValues, expectedUnionDepthValues ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST( RimWellLogCalculatedCurve, calculateValue ) { ASSERT_DOUBLE_EQ( 7.0, RimWellLogCalculatedCurve::calculateValue( 5.0, 2.0, RimWellLogCalculatedCurve::Operators::ADD ) ); ASSERT_DOUBLE_EQ( 3.0, RimWellLogCalculatedCurve::calculateValue( 5.0, 2.0, RimWellLogCalculatedCurve::Operators::SUBTRACT ) ); ASSERT_DOUBLE_EQ( 2.5, RimWellLogCalculatedCurve::calculateValue( 5.0, 2.0, RimWellLogCalculatedCurve::Operators::DIVIDE ) ); ASSERT_DOUBLE_EQ( 10.0, RimWellLogCalculatedCurve::calculateValue( 5.0, 2.0, RimWellLogCalculatedCurve::Operators::MULTIPLY ) ); // Divide by zero ASSERT_DOUBLE_EQ( std::numeric_limits::infinity(), RimWellLogCalculatedCurve::calculateValue( 5.0, 0.0, RimWellLogCalculatedCurve::Operators::DIVIDE ) ); }