forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move rest of tests to testament (nim-lang#16140)
* move rest of tests to testament * Update tests/stdlib/tsums.nim
- Loading branch information
Showing
12 changed files
with
228 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import std/editdistance | ||
|
||
doAssert editDistance("", "") == 0 | ||
doAssert editDistance("kitten", "sitting") == 3 # from Wikipedia | ||
doAssert editDistance("flaw", "lawn") == 2 # from Wikipedia | ||
|
||
doAssert editDistance("привет", "превет") == 1 | ||
doAssert editDistance("Åge", "Age") == 1 | ||
# editDistance, one string is longer in bytes, but shorter in rune length | ||
# first string: 4 bytes, second: 6 bytes, but only 3 runes | ||
doAssert editDistance("aaaa", "×××") == 4 | ||
|
||
block veryLongStringEditDistanceTest: | ||
const cap = 256 | ||
var | ||
s1 = newStringOfCap(cap) | ||
s2 = newStringOfCap(cap) | ||
while len(s1) < cap: | ||
s1.add 'a' | ||
while len(s2) < cap: | ||
s2.add 'b' | ||
doAssert editDistance(s1, s2) == cap | ||
|
||
block combiningCodePointsEditDistanceTest: | ||
const s = "A\xCC\x8Age" | ||
doAssert editDistance(s, "Age") == 1 | ||
|
||
doAssert editDistanceAscii("", "") == 0 | ||
doAssert editDistanceAscii("kitten", "sitting") == 3 # from Wikipedia | ||
doAssert editDistanceAscii("flaw", "lawn") == 2 # from Wikipedia | ||
|
||
|
||
assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffix") == 0) | ||
assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffi1") == 1) | ||
assert(editDistance("prefix__hallo_suffix", "prefix__HALLO_suffix") == 5) | ||
assert(editDistance("prefix__hallo_suffix", "prefix__ha_suffix") == 3) | ||
assert(editDistance("prefix__hallo_suffix", "prefix") == 14) | ||
assert(editDistance("prefix__hallo_suffix", "suffix") == 14) | ||
assert(editDistance("prefix__hallo_suffix", "prefix__hao_suffix") == 2) | ||
assert(editDistance("main", "malign") == 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.