From 6bd3a2826fb559d4e88cd2fa5ba89be995553700 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Sun, 24 Dec 2017 09:23:17 -0500 Subject: cmp(x, y: string) now uses memcmp rather than strcmp (#6869) (#6968) --- tests/stdlib/tstring.nim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/stdlib/tstring.nim b/tests/stdlib/tstring.nim index 904bc462a..660746150 100644 --- a/tests/stdlib/tstring.nim +++ b/tests/stdlib/tstring.nim @@ -56,4 +56,24 @@ proc test_string_slice() = echo("OK") +proc test_string_cmp() = + let world = "hello\0world" + let earth = "hello\0earth" + let short = "hello\0" + let hello = "hello" + let goodbye = "goodbye" + + doAssert world == world + doAssert world != earth + doAssert world != short + doAssert world != hello + doAssert world != goodbye + + doAssert cmp(world, world) == 0 + doAssert cmp(world, earth) > 0 + doAssert cmp(world, short) > 0 + doAssert cmp(world, hello) > 0 + doAssert cmp(world, goodbye) > 0 + test_string_slice() +test_string_cmp() -- cgit 1.4.1-2-gfad0