about summary refs log tree commit diff
path: root/users/sterni/nix/utf8/tests/default.nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-11-23T18·23+0100
committersterni <sternenseemann@systemli.org>2021-11-25T11·15+0100
commit87a0aaa77dd94a5a83e4cc0d00e06528d5ce8edc (patch)
tree30b8cc68cba18b3c06c851af2d095e9d69f0cb23 /users/sterni/nix/utf8/tests/default.nix
parent9370ea5e3303359a9c25417b0b8210d174e167e5 (diff)
feat(sterni/nix/utf8): implement UTF-8 encoding r/3091
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
Diffstat (limited to '')
-rw-r--r--users/sterni/nix/utf8/tests/default.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/users/sterni/nix/utf8/tests/default.nix b/users/sterni/nix/utf8/tests/default.nix
index 2f8054fad6..fdc0b06715 100644
--- a/users/sterni/nix/utf8/tests/default.nix
+++ b/users/sterni/nix/utf8/tests/default.nix
@@ -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
   ]