summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorMiran <narimiran@disroot.org>2020-08-25 09:57:15 +0200
committerGitHub <noreply@github.com>2020-08-25 09:57:15 +0200
commit15ff89cec14ea6d1bc05a5975dedfcb6e712720b (patch)
tree79c1e72c6fff15d5610f6515ccb461dbcb797360 /tests
parent5651a2f711ae0ce3eb86400646ca2b7e9ab2988a (diff)
downloadNim-15ff89cec14ea6d1bc05a5975dedfcb6e712720b.tar.gz
[backport] fix #15064, strscans.scanf edge case for '$+' (#15223)
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tstrscans.nim16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/stdlib/tstrscans.nim b/tests/stdlib/tstrscans.nim
index 08fc14e45..6f952368c 100644
--- a/tests/stdlib/tstrscans.nim
+++ b/tests/stdlib/tstrscans.nim
@@ -79,8 +79,22 @@ block EmptyTuple:
 block Arrow:
   let text = "foo;bar;baz;"
   var idx = 0
-  var res = ""
   doAssert scanp(text, idx, +(~{';','\0'} -> (discard $_)), ';')
   doAssert scanp(text, idx, +(~{';','\0'} -> (discard $_)), ';')
   doAssert scanp(text, idx, +(~{';','\0'} -> (discard $_)), ';')
   doAssert scanp(text, idx, +(~{';','\0'} -> (discard $_)), ';') == false
+
+
+block issue15064:
+  var nick1, msg1: string
+  doAssert scanf("<abcd> a", "<$+> $+", nick1, msg1)
+  doAssert nick1 == "abcd"
+  doAssert msg1 == "a"
+
+  var nick2, msg2: string
+  doAssert(not scanf("<abcd> ", "<$+> $+", nick2, msg2))
+
+  var nick3, msg3: string
+  doAssert scanf("<abcd> ", "<$+> $*", nick3, msg3)
+  doAssert nick3 == "abcd"
+  doAssert msg3 == ""