aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2017-11-01 18:55:52 +0200
committerOskari Timperi <oskari.timperi@iki.fi>2017-11-01 18:55:52 +0200
commit1cb88f9540c7f9c4398c13b83c2594816fa28369 (patch)
treedcb078c6f230f61a6b6a91871be8726540bdf4f5 /tests
parentfecdbdffdcfcf7b86f7e836ade6157b21c000be0 (diff)
downloadnimrec-master.tar.gz
nimrec-master.zip
Add real validationHEADmaster
Diffstat (limited to 'tests')
-rw-r--r--tests/test.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test.nim b/tests/test.nim
index 3eda4eb..06c7ce0 100644
--- a/tests/test.nim
+++ b/tests/test.nim
@@ -433,3 +433,28 @@ suite "type basics: integers":
let data = prologue & "Value: " & value & "\n"
expect(Exception):
discard toSeq(recordsInSet(newStringStream(data), "Entry"))
+
+suite "type basics: reals":
+ const prologue = """
+%rec: Entry
+%type: Value real
+
+"""
+
+ test "valid reals":
+ const values = ["0", "1", "123456789", "987654321", "-123456789",
+ "-987654321", "-0",
+ "0.0", "0.12345", "1234.5678",
+ "1e8", "1E8", "1e+9", "1E-9", "1e10"]
+
+ for value in values:
+ let data = prologue & "Value: " & value & "\n"
+ discard toSeq(recordsInSet(newStringStream(data), "Entry"))
+
+ test "invalid reals":
+ const values = ["0.", "foobar", "01", "1-"]
+
+ for value in values:
+ let data = prologue & "Value: " & value & "\n"
+ expect(Exception):
+ discard toSeq(recordsInSet(newStringStream(data), "Entry"))