diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 9ff924952b..c5204fd68c 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -1897,7 +1897,7 @@ void RimWellRftPlot::initializeDataSources( RimWellRftPlot* source ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::variant RimWellRftPlot::dataSource() const +std::variant RimWellRftPlot::dataSource() const { // Return the first selected ensemble, if any // If no ensemble is selected, return the first selected summary case, if any diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h index db462a6daa..3bc2f62c77 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h @@ -88,7 +88,8 @@ public: int branchIndex() const; - std::variant dataSource() const; + // The monostate is used to indicate that no data source is selected + std::variant dataSource() const; static const char* plotNameFormatString(); diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index 3cc008a9ca..7158b399e2 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -76,6 +76,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathValve-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellRftPlot-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimDataFilterCollection-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader-Test.cpp diff --git a/ApplicationLibCode/UnitTests/RimWellRftPlot-Test.cpp b/ApplicationLibCode/UnitTests/RimWellRftPlot-Test.cpp new file mode 100644 index 0000000000..dac891fc4c --- /dev/null +++ b/ApplicationLibCode/UnitTests/RimWellRftPlot-Test.cpp @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026 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 "RimSummaryCase.h" +#include "RimSummaryEnsemble.h" +#include "RimWellRftPlot.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// A plot with no selected sources must not report a summary case or ensemble data source +//-------------------------------------------------------------------------------------------------- +TEST( RimWellRftPlotTest, DataSourceWithoutSelectedSources ) +{ + RimWellRftPlot plot; + + auto dataSource = plot.dataSource(); + + EXPECT_TRUE( std::holds_alternative( dataSource ) ); + EXPECT_EQ( nullptr, std::get_if( &dataSource ) ); + EXPECT_EQ( nullptr, std::get_if( &dataSource ) ); +}