summary refs log tree commit diff stats
path: root/tests/system/tnewstring_uninitialized.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-08-29 19:29:42 +0800
committerGitHub <noreply@github.com>2023-08-29 13:29:42 +0200
commite53c66ef39e9f6b521835399677430c2c980ee64 (patch)
treec3595fd22e54673a7b2d9ccd211054fd66ad9076 /tests/system/tnewstring_uninitialized.nim
parent1fcb53cded47a9671671170f0df42f6efbde5be4 (diff)
downloadNim-e53c66ef39e9f6b521835399677430c2c980ee64.tar.gz
fixes #22555; implements `newStringUninit` (#22572)
* fixes newStringUninitialized; implement `newStringUninitialized`

* add a simple test case

* adds a changelog

* Update lib/system.nim

* Apply suggestions from code review

rename to newStringUninit
Diffstat (limited to 'tests/system/tnewstring_uninitialized.nim')
-rw-r--r--tests/system/tnewstring_uninitialized.nim11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/system/tnewstring_uninitialized.nim b/tests/system/tnewstring_uninitialized.nim
new file mode 100644
index 000000000..9bc0e1622
--- /dev/null
+++ b/tests/system/tnewstring_uninitialized.nim
@@ -0,0 +1,11 @@
+discard """
+  matrix: "--mm:refc;"
+"""
+
+# bug #22555
+var x = newStringUninit(10)
+doAssert x.len == 10
+for i in 0..<x.len:
+  x[i] = chr(ord('a') + i)
+
+doAssert x == "abcdefghij"