[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master a90141a 1/4: Add a unit test: a rate table ma
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master a90141a 1/4: Add a unit test: a rate table may have zero decimals |
Date: |
Fri, 11 Nov 2016 22:46:10 +0000 (UTC) |
branch: master
commit a90141a830cb10c64148da70fc9e96d5d58ce9be
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Add a unit test: a rate table may have zero decimals
This new unit test fails for the time being.
---
rate_table_test.cpp | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/rate_table_test.cpp b/rate_table_test.cpp
index a55bffe..384e936 100644
--- a/rate_table_test.cpp
+++ b/rate_table_test.cpp
@@ -235,6 +235,20 @@ std::string const simple_table_values(1 + R"table(
/// Minimal valid SOA table in text format.
std::string const simple_table_text(simple_table_header + simple_table_values);
+/// A table with zero decimals. The original SOA code, and the code in
+/// 'rate_table.cpp', both write these table values in a field of width
+/// four: two spaces between columns, plus one for the data, plus one
+/// for a nonexistent decimal point.
+std::string const integral_table(1 + R"table(
+Table number: 1
+Table type: Aggregate
+Minimum age: 0
+Maximum age: 1
+Number of decimal places: 0
+Table values:
+ 0 0
+ 1 1
+)table");
} // Unnamed namespace.
/// Test opening database files.
@@ -358,7 +372,7 @@ void test_from_text()
,lmi_test::what_regex("expected a field")
);
- // And so should using too few of them: chop of the last line to test.
+ // And so should using too few of them: chop off the last line to test.
BOOST_TEST_THROW
(table::read_from_text(simple_table_header + " 0 0.12345")
,std::runtime_error
@@ -378,6 +392,9 @@ void test_from_text()
+" 0 0.12345\n"
" 1 10.98765\n"
);
+
+ // The number of decimals may be zero.
+ table::read_from_text(integral_table);
}
void test_save()