mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add test for table formatter
This commit is contained in:
parent
b79a340333
commit
e3e7ededf8
@ -46,6 +46,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryAddress-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaTimeHistoryCurveTools-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/SolveSpaceSolver-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaPolyArcLineSampler-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifEclipseDataTableFormatter-Test.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,75 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RifEclipseDataTableFormatter.h"
|
||||
|
||||
TEST(RifEclipseDataTableFormatter, BasicUsage)
|
||||
{
|
||||
QString tableText;
|
||||
QTextStream stream(&tableText);
|
||||
RifEclipseDataTableFormatter formatter(stream);
|
||||
|
||||
|
||||
std::vector<RifEclipseOutputTableColumn> header = {
|
||||
RifEclipseOutputTableColumn("Well"),
|
||||
RifEclipseOutputTableColumn("Integer Number"),
|
||||
RifEclipseOutputTableColumn("IntNumer 2"),
|
||||
RifEclipseOutputTableColumn("IntNumer 3"),
|
||||
};
|
||||
|
||||
formatter.header(header);
|
||||
|
||||
formatter.add("well a");
|
||||
formatter.add(1);
|
||||
formatter.add(2);
|
||||
formatter.add(3);
|
||||
formatter.rowCompleted();
|
||||
|
||||
formatter.add("well B");
|
||||
formatter.add(12);
|
||||
formatter.add(23);
|
||||
formatter.add(233);
|
||||
formatter.rowCompleted();
|
||||
|
||||
formatter.tableCompleted();
|
||||
|
||||
std::cout << tableText.toStdString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST(RifEclipseDataTableFormatter, NoPrefix)
|
||||
{
|
||||
QString tableText;
|
||||
QTextStream stream(&tableText);
|
||||
RifEclipseDataTableFormatter formatter(stream);
|
||||
|
||||
formatter.setTableRowPrependText(" ");
|
||||
formatter.setTableRowLineAppendText("");
|
||||
|
||||
|
||||
std::vector<RifEclipseOutputTableColumn> header = {
|
||||
RifEclipseOutputTableColumn("Well"),
|
||||
RifEclipseOutputTableColumn("Integer Number", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||
RifEclipseOutputTableColumn("IntNumer 2", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||
RifEclipseOutputTableColumn("IntNumer 3", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||
};
|
||||
|
||||
formatter.header(header);
|
||||
|
||||
formatter.add("well a");
|
||||
formatter.add(1);
|
||||
formatter.add(2);
|
||||
formatter.add(3);
|
||||
formatter.rowCompleted();
|
||||
|
||||
formatter.add("well B");
|
||||
formatter.add(12);
|
||||
formatter.add(231);
|
||||
formatter.add(23123);
|
||||
formatter.rowCompleted();
|
||||
|
||||
formatter.tableCompleted();
|
||||
|
||||
std::cout << tableText.toStdString();
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user