mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 15:14:07 -06:00
f8c5cf389f
* Set column width to 140 * Use c++20 * Remove redundant virtual
65 lines
2.7 KiB
C++
65 lines
2.7 KiB
C++
#include "gtest/gtest.h"
|
|
|
|
#include "RiaTestDataDirectory.h"
|
|
|
|
#include "RifPressureDepthTextFileReader.h"
|
|
#include "RigPressureDepthData.h"
|
|
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
|
|
static const QString CASE_REAL_TEST_DATA_DIRECTORY_04 = QString( "%1/RifPressureDepthTextFileReader/" ).arg( TEST_DATA_DIR );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RifPressureDepthTextFileReaderTest, LoadFile )
|
|
{
|
|
QString fileName = CASE_REAL_TEST_DATA_DIRECTORY_04 + "example_file.txt";
|
|
|
|
auto [items, errorMessage] = RifPressureDepthTextFileReader::readFile( fileName );
|
|
|
|
EXPECT_TRUE( errorMessage.isEmpty() );
|
|
ASSERT_EQ( 3u, items.size() );
|
|
|
|
EXPECT_EQ( "G-14", items[0].wellName().toStdString() );
|
|
EXPECT_EQ( 28, items[0].timeStep().date().day() );
|
|
EXPECT_EQ( 12, items[0].timeStep().date().month() );
|
|
EXPECT_EQ( 1995, items[0].timeStep().date().year() );
|
|
std::vector<std::pair<double, double>> values0 = items[0].getPressureDepthValues();
|
|
EXPECT_EQ( 4u, values0.size() );
|
|
double delta = 0.001;
|
|
EXPECT_NEAR( 418.88, values0[0].first, delta );
|
|
EXPECT_NEAR( 2726.91, values0[0].second, delta );
|
|
|
|
EXPECT_EQ( "G-14", items[1].wellName().toStdString() );
|
|
EXPECT_EQ( 28, items[1].timeStep().date().day() );
|
|
EXPECT_EQ( 12, items[1].timeStep().date().month() );
|
|
EXPECT_EQ( 1996, items[1].timeStep().date().year() );
|
|
std::vector<std::pair<double, double>> values1 = items[1].getPressureDepthValues();
|
|
EXPECT_NEAR( 418.88, values1[0].first, delta );
|
|
EXPECT_NEAR( 2726.91, values1[0].second, delta );
|
|
|
|
EXPECT_EQ( "F-56", items[2].wellName().toStdString() );
|
|
EXPECT_EQ( 15, items[2].timeStep().date().day() );
|
|
EXPECT_EQ( 1, items[2].timeStep().date().month() );
|
|
EXPECT_EQ( 2012, items[2].timeStep().date().year() );
|
|
std::vector<std::pair<double, double>> values2 = items[2].getPressureDepthValues();
|
|
EXPECT_EQ( 7u, values2.size() );
|
|
EXPECT_NEAR( 413.32, values2[6].first, delta );
|
|
EXPECT_NEAR( 2896.555, values2[6].second, delta );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RifPressureDepthTextFileReaderTest, LoadFileNonExistingFiles )
|
|
{
|
|
QString fileName = CASE_REAL_TEST_DATA_DIRECTORY_04 + "this_file_does_not_exist.csv";
|
|
|
|
auto [items, errorMessage] = RifPressureDepthTextFileReader::readFile( fileName );
|
|
|
|
EXPECT_FALSE( errorMessage.isEmpty() );
|
|
EXPECT_EQ( 0u, items.size() );
|
|
}
|