From 8fab18d4c153d7bd4fbb42fd81465be9206ce067 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 14 Aug 2023 23:29:00 +0200 Subject: [PATCH] lib.removePrefix: Add tests --- lib/tests/misc.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index dcfa4c540f0c..6d55ae684771 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -349,6 +349,27 @@ runTests { expected = true; }; + testRemovePrefixExample1 = { + expr = removePrefix "foo." "foo.bar.baz"; + expected = "bar.baz"; + }; + testRemovePrefixExample2 = { + expr = removePrefix "xxx" "foo.bar.baz"; + expected = "foo.bar.baz"; + }; + testRemovePrefixEmptyPrefix = { + expr = removePrefix "" "foo"; + expected = "foo"; + }; + testRemovePrefixEmptyString = { + expr = removePrefix "foo" ""; + expected = ""; + }; + testRemovePrefixEmptyBoth = { + expr = removePrefix "" ""; + expected = ""; + }; + testNormalizePath = { expr = strings.normalizePath "//a/b//c////d/"; expected = "/a/b/c/d/";