mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 08:25:03 -05:00
Fix unit test build problem
This commit is contained in:
1 parent
4e5925808a
commit
66c58bad28
1 file changed
+97
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
#include "RifEclipseDataTableFormatter.h"
|
#include "RifEclipseDataTableFormatter.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
TEST(RifEclipseDataTableFormatter, BasicUsage)
|
TEST(RifEclipseDataTableFormatter, BasicUsage)
|
||||||
{
|
{
|
||||||
QString tableText;
|
QString tableText;
|
||||||
@@ -117,4 +120,98 @@ TEST(RifEclipseDataTableFormatter, LongLine)
|
|||||||
EXPECT_LE(line.length(), RifEclipseDataTableFormatter::maxEclipseRowWidth());
|
EXPECT_LE(line.length(), RifEclipseDataTableFormatter::maxEclipseRowWidth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(RifEclipseDataTableFormatter, LongLine132)
|
||||||
|
{
|
||||||
|
QString tableText;
|
||||||
|
QTextStream stream(&tableText);
|
||||||
|
RifEclipseDataTableFormatter formatter(stream);
|
||||||
|
|
||||||
|
std::vector<RifEclipseOutputTableColumn> header = {
|
||||||
|
RifEclipseOutputTableColumn("10 Char"),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #1", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #2", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #3", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #4", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #5", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #6", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #7", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("I", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
};
|
||||||
|
|
||||||
|
formatter.header(header);
|
||||||
|
QString fiftyCharacterWellName = "01234567890";
|
||||||
|
formatter.add(fiftyCharacterWellName);
|
||||||
|
for (int i = 0; i < 7; ++i)
|
||||||
|
{
|
||||||
|
formatter.add(std::numeric_limits<int>::max()); // 10 characters
|
||||||
|
}
|
||||||
|
formatter.add(11);
|
||||||
|
|
||||||
|
int fullLineLength = formatter.tableRowPrependText().length() + 9 * formatter.columnSpacing() + 10 + 7 * 10 + 2 +
|
||||||
|
formatter.tableRowAppendText().length();
|
||||||
|
int tableWidth = formatter.tableWidth();
|
||||||
|
EXPECT_GE(tableWidth, fullLineLength);
|
||||||
|
EXPECT_EQ(RifEclipseDataTableFormatter::maxEclipseRowWidth(), fullLineLength);
|
||||||
|
|
||||||
|
formatter.rowCompleted();
|
||||||
|
formatter.tableCompleted();
|
||||||
|
std::cout << tableText.toStdString() << std::endl;
|
||||||
|
|
||||||
|
QStringList tableLines = tableText.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
|
||||||
|
for (QString line : tableLines)
|
||||||
|
{
|
||||||
|
if (line.startsWith("0"))
|
||||||
|
{
|
||||||
|
EXPECT_EQ(line.length(), RifEclipseDataTableFormatter::maxEclipseRowWidth());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(RifEclipseDataTableFormatter, LongLine133)
|
||||||
|
{
|
||||||
|
QString tableText;
|
||||||
|
QTextStream stream(&tableText);
|
||||||
|
RifEclipseDataTableFormatter formatter(stream);
|
||||||
|
|
||||||
|
std::vector<RifEclipseOutputTableColumn> header = {
|
||||||
|
RifEclipseOutputTableColumn("10 Char"),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #1", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #2", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #3", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #4", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #5", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #6", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("10 Int #7", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
RifEclipseOutputTableColumn("I", RifEclipseOutputTableDoubleFormatting(), RIGHT),
|
||||||
|
};
|
||||||
|
|
||||||
|
formatter.header(header);
|
||||||
|
QString fiftyCharacterWellName = "01234567890";
|
||||||
|
formatter.add(fiftyCharacterWellName);
|
||||||
|
for (int i = 0; i < 7; ++i)
|
||||||
|
{
|
||||||
|
formatter.add(std::numeric_limits<int>::max()); // 10 characters
|
||||||
|
}
|
||||||
|
formatter.add(111);
|
||||||
|
|
||||||
|
int fullLineLength = formatter.tableRowPrependText().length() + 9 * formatter.columnSpacing() + 10 + 7 * 10 + 3 +
|
||||||
|
formatter.tableRowAppendText().length();
|
||||||
|
int tableWidth = formatter.tableWidth();
|
||||||
|
EXPECT_GE(tableWidth, fullLineLength);
|
||||||
|
EXPECT_LT(RifEclipseDataTableFormatter::maxEclipseRowWidth(), fullLineLength);
|
||||||
|
|
||||||
|
formatter.rowCompleted();
|
||||||
|
formatter.tableCompleted();
|
||||||
|
std::cout << tableText.toStdString() << std::endl;
|
||||||
|
|
||||||
|
QStringList tableLines = tableText.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
|
||||||
|
for (QString line : tableLines)
|
||||||
|
{
|
||||||
|
if (line.startsWith("0"))
|
||||||
|
{
|
||||||
|
EXPECT_LE(line.length(), RifEclipseDataTableFormatter::maxEclipseRowWidth());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user