feat(sterni/nix/utf8): implement UTF-8 encoding
This implementation is still a bit rough as it doesn't check if the produced string is valid UTF-8 which may happen if an invalid Unicode codepoint is passed. Change-Id: Ibaa91dafa8937142ef704a175efe967b62e3ee7b
This commit is contained in:
parent
9370ea5e33
commit
87a0aaa77d
2 changed files with 83 additions and 2 deletions
|
|
@ -113,9 +113,19 @@ let
|
|||
randomUnicode
|
||||
]));
|
||||
|
||||
testDecodingEncoding = it "checks that decoding and then encoding forms an identity"
|
||||
(builtins.map
|
||||
(s: assertEq "Decoding and then encoding “${s}” yields itself"
|
||||
(utf8.encode (utf8.decode s)) s)
|
||||
(lib.flatten [
|
||||
glassSentences
|
||||
randomUnicode
|
||||
]));
|
||||
|
||||
in
|
||||
runTestsuite "nix.utf8" [
|
||||
testFailures
|
||||
testAscii
|
||||
testDecoding
|
||||
testDecodingEncoding
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue