2020-04-30 16:54:25 +02:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
2020-11-18 14:01:54 +01:00
|
|
|
#include "RiaTestDataDirectory.h"
|
2026-02-27 10:30:35 +01:00
|
|
|
#include "RifFormationNamesReader.h"
|
2020-04-30 16:54:25 +02:00
|
|
|
#include "RigFormationNames.h"
|
|
|
|
|
|
2020-11-18 14:01:54 +01:00
|
|
|
#include "cvfColor3.h"
|
|
|
|
|
|
|
|
|
|
#include <QDir>
|
2020-04-30 16:54:25 +02:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
2026-02-27 10:30:35 +01:00
|
|
|
TEST( RifFormationNamesReader, ReadLYRFileWithoutColor )
|
2020-04-30 16:54:25 +02:00
|
|
|
{
|
|
|
|
|
QDir baseFolder( TEST_DATA_DIR );
|
|
|
|
|
|
2026-02-27 10:30:35 +01:00
|
|
|
const QString filename( "RifFormationNamesReader/Norne_ATW2013.lyr" );
|
2020-04-30 16:54:25 +02:00
|
|
|
const QString filePath = baseFolder.absoluteFilePath( filename );
|
|
|
|
|
EXPECT_TRUE( QFile::exists( filePath ) );
|
|
|
|
|
|
2026-08-05 11:23:42 +02:00
|
|
|
auto fm = RifFormationNamesReader::readFormationNamesFile( filePath );
|
|
|
|
|
ASSERT_TRUE( fm.has_value() );
|
2020-04-30 16:54:25 +02:00
|
|
|
|
|
|
|
|
QString formationName_K1 = fm->formationNameFromKLayerIdx( 0 );
|
|
|
|
|
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE( formationName_K1 == "Garn 3" );
|
|
|
|
|
EXPECT_EQ( 1, formationIndex );
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-27 10:30:35 +01:00
|
|
|
TEST( RifFormationNamesReader, ReadLYRFileWithColorName )
|
2020-04-30 16:54:25 +02:00
|
|
|
{
|
|
|
|
|
QDir baseFolder( TEST_DATA_DIR );
|
|
|
|
|
|
2026-02-27 10:30:35 +01:00
|
|
|
const QString filename( "RifFormationNamesReader/Norne_ATW2013ColorName.lyr" );
|
2020-04-30 16:54:25 +02:00
|
|
|
const QString filePath = baseFolder.absoluteFilePath( filename );
|
|
|
|
|
EXPECT_TRUE( QFile::exists( filePath ) );
|
|
|
|
|
|
2026-08-05 11:23:42 +02:00
|
|
|
auto fm = RifFormationNamesReader::readFormationNamesFile( filePath );
|
|
|
|
|
ASSERT_TRUE( fm.has_value() );
|
2020-04-30 16:54:25 +02:00
|
|
|
|
|
|
|
|
QString formationName_K1 = fm->formationNameFromKLayerIdx( 1 );
|
|
|
|
|
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
|
|
|
|
|
|
|
|
|
cvf::Color3f formationColor;
|
|
|
|
|
bool colorPresent = fm->formationColorFromKLayerIdx( 1, &formationColor );
|
|
|
|
|
EXPECT_TRUE( colorPresent );
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE( formationName_K1 == "Garn 2" );
|
|
|
|
|
EXPECT_EQ( 1, formationIndex );
|
|
|
|
|
EXPECT_EQ( 1.0f, formationColor.r() );
|
|
|
|
|
EXPECT_EQ( 0.0f, formationColor.g() );
|
|
|
|
|
EXPECT_EQ( 0.0f, formationColor.b() );
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-27 10:30:35 +01:00
|
|
|
TEST( RifFormationNamesReader, ReadLYRFileWithColorHTML )
|
2020-04-30 16:54:25 +02:00
|
|
|
{
|
|
|
|
|
QDir baseFolder( TEST_DATA_DIR );
|
|
|
|
|
|
2026-02-27 10:30:35 +01:00
|
|
|
const QString filename( "RifFormationNamesReader/Norne_ATW2013ColorHTML.lyr" );
|
2020-04-30 16:54:25 +02:00
|
|
|
const QString filePath = baseFolder.absoluteFilePath( filename );
|
|
|
|
|
EXPECT_TRUE( QFile::exists( filePath ) );
|
|
|
|
|
|
2026-08-05 11:23:42 +02:00
|
|
|
auto fm = RifFormationNamesReader::readFormationNamesFile( filePath );
|
|
|
|
|
ASSERT_TRUE( fm.has_value() );
|
2020-04-30 16:54:25 +02:00
|
|
|
|
|
|
|
|
QString formationName_K1 = fm->formationNameFromKLayerIdx( 1 );
|
|
|
|
|
int formationIndex = fm->formationIndexFromKLayerIdx( 1 );
|
|
|
|
|
|
|
|
|
|
cvf::Color3f formationColor;
|
|
|
|
|
bool colorPresent = fm->formationColorFromKLayerIdx( 1, &formationColor );
|
|
|
|
|
EXPECT_TRUE( colorPresent );
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE( formationName_K1 == "Garn 2" );
|
|
|
|
|
EXPECT_EQ( 1, formationIndex );
|
|
|
|
|
EXPECT_EQ( 1.0f, formationColor.r() );
|
|
|
|
|
EXPECT_EQ( 0.0f, formationColor.g() );
|
|
|
|
|
EXPECT_EQ( 0.0f, formationColor.b() );
|
|
|
|
|
}
|