Skip to content

Commit 6cb0553

Browse files
committed
Add string fuzzer.
1 parent d418588 commit 6cb0553

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/fuzz_strings.nim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import random, jsony, unicode
2+
3+
randomize()
4+
5+
# ASCII
6+
for i in 0 ..< 100_000:
7+
var s = ""
8+
for i in 0 ..< rand(0 .. 100):
9+
s.add char(rand(0 .. 128))
10+
11+
if s.toJson().fromJson(string) != s:
12+
echo "some thing wrong!"
13+
echo repr(s)
14+
15+
# UNICODE
16+
for i in 0 ..< 100_000:
17+
var s = ""
18+
for i in 0 ..< rand(0 .. 100):
19+
s.add $Rune(rand(0 .. 0x10FFFF))
20+
21+
if s.toJson().fromJson(string) != s:
22+
echo "some thing wrong!"
23+
echo repr(s)

0 commit comments

Comments
 (0)