summary refs log tree commit diff stats
path: root/tests/stdlib/tparseutils.nim
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-11-25 02:06:41 +0800
committerGitHub <noreply@github.com>2020-11-24 19:06:41 +0100
commitcbc793b30b10b8e82af7313ac8cd438abf97f7d7 (patch)
tree84c1ee6cc25ef9f4e407d0492c9a66deac87712f /tests/stdlib/tparseutils.nim
parentd306a04466b7f1129620dc3ab35443119ed4c867 (diff)
downloadNim-cbc793b30b10b8e82af7313ac8cd438abf97f7d7.tar.gz
move tests to testament (#16101)
* move tests to testament

* minor

* fix random

* disable test random
Diffstat (limited to 'tests/stdlib/tparseutils.nim')
-rw-r--r--tests/stdlib/tparseutils.nim43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/stdlib/tparseutils.nim b/tests/stdlib/tparseutils.nim
new file mode 100644
index 000000000..3bc54dff1
--- /dev/null
+++ b/tests/stdlib/tparseutils.nim
@@ -0,0 +1,43 @@
+import parseutils
+import sequtils
+
+let input = "$test{}  $this is ${an{  example}}  "
+let expected = @[(ikVar, "test"), (ikStr, "{}  "), (ikVar, "this"),
+                  (ikStr, " is "), (ikExpr, "an{  example}"), (ikStr, "  ")]
+doAssert toSeq(interpolatedFragments(input)) == expected
+
+var value = 0
+discard parseHex("0x38", value)
+doAssert value == 56
+
+value = -1
+doAssert(parseSaturatedNatural("848", value) == 3)
+doAssert value == 848
+
+value = -1
+discard parseSaturatedNatural("84899999999999999999324234243143142342135435342532453", value)
+doAssert value == high(int)
+
+value = -1
+discard parseSaturatedNatural("9223372036854775808", value)
+doAssert value == high(int)
+
+value = -1
+discard parseSaturatedNatural("9223372036854775807", value)
+doAssert value == high(int)
+
+value = -1
+discard parseSaturatedNatural("18446744073709551616", value)
+doAssert value == high(int)
+
+value = -1
+discard parseSaturatedNatural("18446744073709551615", value)
+doAssert value == high(int)
+
+value = -1
+doAssert(parseSaturatedNatural("1_000_000", value) == 9)
+doAssert value == 1_000_000
+
+var i64Value: int64
+discard parseBiggestInt("9223372036854775807", i64Value)
+doAssert i64Value == 9223372036854775807