From 87a0aaa77dd94a5a83e4cc0d00e06528d5ce8edc Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 23 Nov 2021 19:23:54 +0100 Subject: 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 --- users/sterni/nix/utf8/tests/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'users/sterni/nix/utf8/tests/default.nix') diff --git a/users/sterni/nix/utf8/tests/default.nix b/users/sterni/nix/utf8/tests/default.nix index 2f8054fad6d9..fdc0b067156f 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 ] -- cgit 1.4.1