summary refs log tree commit diff stats
path: root/tests/system
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-12-02 03:19:39 +0800
committerGitHub <noreply@github.com>2020-12-01 20:19:39 +0100
commitc65f95417a85a04707712a3b481ffa0b94c99437 (patch)
tree3d23927c9e6773fd05108fd5c099beb8f6ddffd4 /tests/system
parent1d1b3f79fdccfdd359781dbde3c5aea3b67bf05b (diff)
downloadNim-c65f95417a85a04707712a3b481ffa0b94c99437.tar.gz
better addInt (#16160)
* better addint
* Update lib/system/strmantle.nim

Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>
Diffstat (limited to 'tests/system')
-rw-r--r--tests/system/tstrmantle.nim46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/system/tstrmantle.nim b/tests/system/tstrmantle.nim
new file mode 100644
index 000000000..5b232193e
--- /dev/null
+++ b/tests/system/tstrmantle.nim
@@ -0,0 +1,46 @@
+var res = newStringOfCap(24)
+
+for i in 0 .. 9:
+  res.addInt int64(i)
+
+doAssert res == "0123456789"
+
+res = newStringOfCap(24)
+
+for i in -9 .. 0:
+  res.addInt int64(i)
+
+doAssert res == "-9-8-7-6-5-4-3-2-10"
+
+res = newStringOfCap(24)
+res.addInt high(int64)
+doAssert res == "9223372036854775807"
+
+res = newStringOfCap(24)
+res.addInt low(int64)
+doAssert res == "-9223372036854775808"
+
+res = newStringOfCap(12)
+res.addInt high(int32)
+doAssert res == "2147483647"
+
+res = newStringOfCap(12)
+res.addInt low(int32)
+doAssert res == "-2147483648"
+
+res = newStringOfCap(12)
+res.addInt high(int16)
+doAssert res == "32767"
+
+res = newStringOfCap(212)
+res.addInt low(int16)
+doAssert res == "-32768"
+
+
+res = newStringOfCap(12)
+res.addInt high(int8)
+doAssert res == "127"
+
+res = newStringOfCap(12)
+res.addInt low(int8)
+doAssert res == "-128"