1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

Add `number->locale-string' tests.

* test-suite/tests/i18n.test ("number->locale-string"): New test prefix.
This commit is contained in:
Ludovic Courtès 2010-08-06 15:36:51 +02:00
parent 802b47bdc6
commit 61d1d4a83a

View file

@ -1,6 +1,6 @@
;;;; i18n.test --- Exercise the i18n API. -*- coding: utf-8; mode: scheme; -*- ;;;; i18n.test --- Exercise the i18n API. -*- coding: utf-8; mode: scheme; -*-
;;;; ;;;;
;;;; Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. ;;;; Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
;;;; Ludovic Courtès ;;;; Ludovic Courtès
;;;; ;;;;
;;;; This library is free software; you can redistribute it and/or ;;;; This library is free software; you can redistribute it and/or
@ -363,3 +363,44 @@
(string-ci=? result "Tuesday")))) (string-ci=? result "Tuesday"))))
(lambda () (lambda ()
(setlocale LC_ALL "C"))))))) (setlocale LC_ALL "C")))))))
;;;
;;; Numbers.
;;;
(with-test-prefix "number->locale-string"
;; We assume the global locale is "C" at this point.
(with-test-prefix "C"
(pass-if "no thousand separator"
;; Unlike in English, the "C" locale has no thousand separator.
;; If this doesn't hold, the following tests will fail.
(string=? "" (locale-thousands-separator)))
(pass-if "integer"
(string=? "123456" (number->locale-string 123456)))
(pass-if "fraction"
(string=? "1234.567" (number->locale-string 1234.567)))
(pass-if "fraction, 1 digit"
(string=? "1234.5" (number->locale-string 1234.567 1))))
(with-test-prefix "French"
(under-french-locale-or-unresolved
(lambda ()
(let ((fr (make-locale LC_ALL %french-locale-name)))
(pass-if "integer"
(string=? "123 456" (number->locale-string 123456 #t fr)))
(pass-if "fraction"
(string=? "1 234,567" (number->locale-string 1234.567 #t fr)))
(pass-if "fraction, 1 digit"
(string=? "1 234,5"
(number->locale-string 1234.567 1 fr))))))))