summaryrefslogtreecommitdiff
path: root/test-suite/tests/strings.test
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2015-01-22 01:22:19 -0500
committerAndy Wingo <wingo@pobox.com>2016-05-22 19:03:37 +0200
commite390e5760b8811be04665e160d0eb79d3721c453 (patch)
treeddec7d4924e6a888645b6f5de5d2f0b7b1d72a26 /test-suite/tests/strings.test
parent751a55e3552547c84cc3cc0ad69fc6f26bd7251e (diff)
downloadguile-e390e5760b8811be04665e160d0eb79d3721c453.tar.gz
Implement 'string-utf8-length' and 'scm_c_string_utf8_length'.
* libguile/strings.c (utf8_length, scm_c_string_utf8_length) (scm_string_utf8_length): New functions. * libguile/strings.h (scm_c_string_utf8_length, scm_string_utf8_length): New prototypes. * doc/ref/api-data.texi (Bytevectors as Strings): Add docs. * doc/ref/guile.texi: Update manual copyright date to 2015. * test-suite/tests/strings.test (string-utf8-length): Add tests.
Diffstat (limited to 'test-suite/tests/strings.test')
-rw-r--r--test-suite/tests/strings.test20
1 files changed, 18 insertions, 2 deletions
diff --git a/test-suite/tests/strings.test b/test-suite/tests/strings.test
index 56c898c8b..66c8a6b95 100644
--- a/test-suite/tests/strings.test
+++ b/test-suite/tests/strings.test
@@ -1,8 +1,8 @@
;;;; strings.test --- test suite for Guile's string functions -*- scheme -*-
;;;; Jim Blandy <jimb@red-bean.com> --- August 1999
;;;;
-;;;; Copyright (C) 1999, 2001, 2004, 2005, 2006, 2008, 2009, 2010,
-;;;; 2011, 2013 Free Software Foundation, Inc.
+;;;; Copyright (C) 1999, 2001, 2004-2006, 2008-2011, 2013,
+;;;; 2015 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -458,6 +458,22 @@
(equal? (string-normalize-nfkc "\u1e9b\u0323") "\u1e69")))
;;
+;; string-utf8-length
+;;
+
+(with-test-prefix "string-utf8-length"
+
+ (pass-if-exception "wrong type argument"
+ exception:wrong-type-arg
+ (string-utf8-length 50))
+
+ (pass-if-equal 0 (string-utf8-length ""))
+ (pass-if-equal 1 (string-utf8-length "\0"))
+ (pass-if-equal 5 (string-utf8-length "hello"))
+ (pass-if-equal 7 (string-utf8-length "helloλ"))
+ (pass-if-equal 9 (string-utf8-length "ሠላም")))
+
+;;
;; string-ref
;;