diff options
author | Araq <rumpf_a@web.de> | 2018-02-20 01:16:09 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-02-20 01:16:09 +0100 |
commit | 1d1ba4481fb72350f0ee9ea17fa23a04c425629a (patch) | |
tree | 8417bd27e1d01bb771e17c2c127447aaaf99161b /tests | |
parent | 2fcc1637465df3ccc04394ee4703330cc51ee493 (diff) | |
parent | ceebfb3e89e2417129fd9e817885c2d3b23a401f (diff) | |
download | Nim-1d1ba4481fb72350f0ee9ea17fa23a04c425629a.tar.gz |
Merge branch 'devel' of github.com:nim-lang/Nim into devel
Diffstat (limited to 'tests')
-rw-r--r-- | tests/async/tasyncfile.nim | 4 | ||||
-rw-r--r-- | tests/stdlib/ttimes.nim | 49 |
2 files changed, 51 insertions, 2 deletions
diff --git a/tests/async/tasyncfile.nim b/tests/async/tasyncfile.nim index 6c0725c88..aa7f03ab1 100644 --- a/tests/async/tasyncfile.nim +++ b/tests/async/tasyncfile.nim @@ -41,11 +41,11 @@ proc main() {.async.} = await file.write("test2") file.close() file = openAsync(fn, fmWrite) - await file.write("test3") + await file.write("t3") file.close() file = openAsync(fn, fmRead) let data = await file.readAll() - doAssert data == "test3" + doAssert data == "t3" file.close() diff --git a/tests/stdlib/ttimes.nim b/tests/stdlib/ttimes.nim index 1f8ae6a22..ae056a79f 100644 --- a/tests/stdlib/ttimes.nim +++ b/tests/stdlib/ttimes.nim @@ -131,6 +131,10 @@ template parseTest(s, f, sExpected: string, ydExpected: int) = echo parsed.yearday, " exp: ", ydExpected check(parsed.yearday == ydExpected) +template parseTestExcp(s, f: string) = + expect ValueError: + let parsed = s.parse(f) + template parseTestTimeOnly(s, f, sExpected: string) = check sExpected in $s.parse(f, utc()) @@ -281,6 +285,51 @@ suite "ttimes": test "parseTest": runTimezoneTests() + test "incorrect inputs: empty string": + parseTestExcp("", "yyyy-MM-dd") + + test "incorrect inputs: year": + parseTestExcp("20-02-19", "yyyy-MM-dd") + + test "incorrect inputs: month number": + parseTestExcp("2018-2-19", "yyyy-MM-dd") + + test "incorrect inputs: month name": + parseTestExcp("2018-Fe", "yyyy-MMM-dd") + + test "incorrect inputs: day": + parseTestExcp("2018-02-1", "yyyy-MM-dd") + + test "incorrect inputs: day of week": + parseTestExcp("2018-Feb-Mo", "yyyy-MMM-ddd") + + test "incorrect inputs: hour": + parseTestExcp("2018-02-19 1:30", "yyyy-MM-dd hh:mm") + + test "incorrect inputs: minute": + parseTestExcp("2018-02-19 16:3", "yyyy-MM-dd hh:mm") + + test "incorrect inputs: second": + parseTestExcp("2018-02-19 16:30:0", "yyyy-MM-dd hh:mm:ss") + + test "incorrect inputs: timezone (z)": + parseTestExcp("2018-02-19 16:30:00 ", "yyyy-MM-dd hh:mm:ss z") + + test "incorrect inputs: timezone (zz) 1": + parseTestExcp("2018-02-19 16:30:00 ", "yyyy-MM-dd hh:mm:ss zz") + + test "incorrect inputs: timezone (zz) 2": + parseTestExcp("2018-02-19 16:30:00 +1", "yyyy-MM-dd hh:mm:ss zz") + + test "incorrect inputs: timezone (zzz) 1": + parseTestExcp("2018-02-19 16:30:00 ", "yyyy-MM-dd hh:mm:ss zzz") + + test "incorrect inputs: timezone (zzz) 2": + parseTestExcp("2018-02-19 16:30:00 +01:", "yyyy-MM-dd hh:mm:ss zzz") + + test "incorrect inputs: timezone (zzz) 3": + parseTestExcp("2018-02-19 16:30:00 +01:0", "yyyy-MM-dd hh:mm:ss zzz") + test "dynamic timezone": proc staticOffset(offset: int): Timezone = proc zoneInfoFromTz(adjTime: Time): ZonedTime = |