#3910 Unit test for table formatter and split text

This commit is contained in:
Gaute Lindkvist
2018-12-19 15:06:14 +01:00
parent 708f24943b
commit 4e5925808a
3 changed files with 67 additions and 4 deletions

View File

@@ -73,3 +73,48 @@ TEST(RifEclipseDataTableFormatter, NoPrefix)
std::cout << tableText.toStdString();
}
TEST(RifEclipseDataTableFormatter, LongLine)
{
QString tableText;
QTextStream stream(&tableText);
RifEclipseDataTableFormatter formatter(stream);
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("50 Character Well Name"),
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("10 Int #8", RifEclipseOutputTableDoubleFormatting(), RIGHT),
};
formatter.header(header);
QString fiftyCharacterWellName = "01234567890123456789012345678901234567890123456789";
formatter.add(fiftyCharacterWellName);
for (int i = 0; i < 8; ++i)
{
formatter.add(std::numeric_limits<int>::max()); // 10 characters
}
int fullLineLength = formatter.tableRowPrependText().length() + 9 * formatter.columnSpacing() +
50 + 8 * 10 + formatter.tableRowAppendText().length();
int tableWidth = formatter.tableWidth();
EXPECT_EQ(tableWidth, fullLineLength);
EXPECT_GT(tableWidth, RifEclipseDataTableFormatter::maxEclipseRowWidth());
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(formatter.commentPrefix()))
{
EXPECT_LE(line.length(), RifEclipseDataTableFormatter::maxEclipseRowWidth());
}
}
}