source: project/release/4/locale/trunk/tests/run.scm @ 15661

Last change on this file since 15661 was 15661, checked in by Kon Lovett, 11 years ago

Save.

File size: 3.1 KB
Line 
1;;;; locale-test.scm
2
3(use test)
4(use locale posix)
5
6(test-group "Locale"
7
8        (test-group "Posix Timezone"
9
10    (test-assert "F1" (not (posix-timezone-string->timezone-components ":foo,bar,baz")))
11    (test-assert "F2" (not (posix-timezone-string->timezone-components "23,foo")))
12    (test-assert "F3" (not (posix-timezone-string->timezone-components "foo/23")))
13    (test-assert "F4" (not (posix-timezone-string->timezone-components "foo-23bar/23")))
14    (test-assert "F5" (not (posix-timezone-string->timezone-components "foo-23bar-22/23")))
15
16          (let ((tz0 (make-timezone-components "PST+8:00" "TEST"))
17          (tz1 (make-timezone-components "PST+8:00PDT+7:00:00" '("POSIX" "TZ")))
18          (tz2 (make-timezone-components "PST+8:00PDT7,J23/12:34,34/1:00:01" "TEST")) )
19
20      (set! tz0
21        (update-timezone-components! tz0
22          'std-name "PST" 'std-offset (* 8 60 60)))
23      (test "S1" tz0
24        (posix-timezone-string->timezone-components "PST+8:00" "TEST"))
25
26      (set! tz1
27        (update-timezone-components! tz1
28          'std-name "PST" 'std-offset (* 8 60 60)
29          'dst-name "PDT" 'dst-offset (* 7 60 60)
30          'dst-start (make-timezone-dst-rule-mwd 4 1 0 3600)
31          'dst-end (make-timezone-dst-rule-mwd 10 5 0 3600)))
32      (test "S2" tz1
33        (posix-timezone-string->timezone-components "PST+8:00PDT+7:00:00,M4.1.0,M10.5" '("POSIX" "TZ")))
34
35      (set! tz2
36        (update-timezone-components! tz2
37          'std-name "PST" 'std-offset (* 8 60 60)
38          'dst-name "PDT" 'dst-offset (* 7 60 60)
39          'dst-start (make-timezone-dst-rule-julian-noleap 23 (+ (* 12 60 60) (* 34 60)))
40          'dst-end (make-timezone-dst-rule-julian-leap 34 (+ (* 1 60 60) 1))))
41      (test "S3" tz2
42        (posix-timezone-string->timezone-components "PST+8:00PDT7,J23/12:34,34/1:00:01" "TEST"))
43
44      (setenv "TZ" "PST+8:00PDT+7:00:00,M4.1.0,M10.5")
45      (posix-load-timezone)
46      (test "S4" tz1 (current-timezone-components)) )
47        )
48
49        (test-group "Posix Locale"
50
51          (let ((lc0 (make-locale-components "en_US" '("POSIX" "LANG")))
52          (lc1 (make-locale-components "en-Latn_US.UTF8@foo,bar,baz" "TEST")) )
53
54      (set! lc0
55        (update-locale-components! lc0
56          'language "en"
57          'region "US"))
58      (set! lc1
59        (update-locale-components! lc1
60          'language "en"
61          'script "Latn"
62          'region "US"
63          'codeset "UTF8"
64          'modifier "foo,bar,baz"))
65
66      (test-assert "F1" (not (posix-locale-string->locale-components "/foo,bar,baz" "TEST")))
67      (test-assert "F2" (not (posix-locale-string->locale-components "23,bar,baz" "TEST")))
68      (test-assert "F3" (not (posix-locale-string->locale-components "foo-bar_1" "TEST")))
69
70      (test "S1" lc0 (posix-locale-string->locale-components "en_US" '("POSIX" "LANG")))
71      (test "S2" lc1 (posix-locale-string->locale-components "en-Latn_US.UTF8@foo,bar,baz" "TEST"))
72
73      (setenv "LANG" "en_US")
74      (posix-load-locale)
75      (test "S3" lc0 (current-locale-components))
76      (test "S4" lc0 (locale-category-ref 'monetary)) )
77        )
78
79  #;
80        (test-group "Local Timezone"
81          (with-tzset "" (lambda () ))
82        )
83)
Note: See TracBrowser for help on using the repository browser.