summary refs log tree commit diff
path: root/tests/utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-11-12 22:56:13 +0100
committerLudovic Courtès <ludo@gnu.org>2013-11-13 00:29:05 +0100
commit56b943de6e61f41d6ebd2dfa65ff886cdfd83759 (patch)
tree3669027822242116653430944897e0a27ca58f55 /tests/utils.scm
parentbe0f611208b4e6d730991267f69f9effe703e32f (diff)
downloadguix-56b943de6e61f41d6ebd2dfa65ff886cdfd83759.tar.gz
utils: Add 'string-replace-substring'.
* guix/utils.scm (string-replace-substring): New procedure.  Based on
  code by Mark H. Weaver.
* tests/utils.scm ("string-replace-substring"): New test.
Diffstat (limited to 'tests/utils.scm')
-rw-r--r--tests/utils.scm8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm
index 4f6ecc514d..017d9170fa 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -82,6 +82,14 @@
         (string-tokenize* "foo!bar!" "!")
         (string-tokenize* "foo+-+bar+-+baz" "+-+")))
 
+(test-equal "string-replace-substring"
+  '("foo BAR! baz"
+    "/gnu/store/chbouib"
+    "")
+  (list (string-replace-substring "foo bar baz" "bar" "BAR!")
+        (string-replace-substring "/nix/store/chbouib" "/nix/" "/gnu/")
+        (string-replace-substring "" "foo" "bar")))
+
 (test-equal "fold2, 1 list"
     (list (reverse (iota 5))
           (map - (reverse (iota 5))))