mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4589 Recursive Import Dialog: Add a method to extract the root path from a search path string. Also added unit test for this
This commit is contained in:
@@ -51,6 +51,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaWeightedMean-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedGeometricMeanCalculator-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedHarmonicMeanCalculator-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaFilePathTools-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Intersect-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions-Test.cpp
|
||||
|
||||
85
ApplicationCode/UnitTests/RiaFilePathTools-Test.cpp
Normal file
85
ApplicationCode/UnitTests/RiaFilePathTools-Test.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RiaFilePathTools.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
std::ostream& operator<< (std::ostream& out, const QString & text)
|
||||
{
|
||||
out << text.toStdString();
|
||||
return out;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RiaFilePathTools, rootSearchPathFromSearchFilter)
|
||||
{
|
||||
{
|
||||
QString testPath("");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString(""), resultRootPath);
|
||||
}
|
||||
|
||||
{
|
||||
QString testPath("D:/");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("D:/"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("D:/A");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("D:/A"), resultRootPath);
|
||||
}
|
||||
|
||||
{
|
||||
QString testPath("D:/A/B[cd]/E");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("D:/A"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("/A/B[cd]/E");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("/A"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("/A/B?/E");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("/A"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("//A/B/E*");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("//A/B"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("//A/B/E");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("//A/B/E"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("//A/B/E/");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("//A/B/E/"), resultRootPath);
|
||||
}
|
||||
|
||||
{
|
||||
QString testPath("//A/B[[]/E/");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("//A/B[[]/E/"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("//A/B[]]/E/");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("//A/B[]]/E/"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("//A/B[*]/E/");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("//A/B[*]/E/"), resultRootPath);
|
||||
}
|
||||
{
|
||||
QString testPath("//A/B[?]/E/");
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter(testPath);
|
||||
EXPECT_EQ(QString("//A/B[?]/E/"), resultRootPath);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user