]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0204-gettext-reencode-sanity.sh
The third batch
[thirdparty/git.git] / t / t0204-gettext-reencode-sanity.sh
CommitLineData
5e9637c6
ÆAB
1#!/bin/sh
2#
3# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
4#
5
6test_description="Gettext reencoding of our *.po/*.mo files works"
7
618200d2 8TEST_PASSES_SANITIZE_LEAK=true
5e9637c6
ÆAB
9. ./lib-gettext.sh
10
9b9f46f5
JH
11# The constants used in a tricky observation for undefined behaviour
12RUNES="TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ"
13PUNTS="TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????"
14MSGKEY="TEST: Old English Runes"
5e9637c6
ÆAB
15
16test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Icelandic' '
17 printf "TILRAUN: Halló Heimur!" >expect &&
18 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Hello World!" >actual &&
19 test_cmp expect actual
20'
21
22test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Runes' '
9b9f46f5
JH
23 printf "%s" "$RUNES" >expect &&
24 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "$MSGKEY" >actual &&
5e9637c6
ÆAB
25 test_cmp expect actual
26'
27
28test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Icelandic' '
29 printf "TILRAUN: Halló Heimur!" | iconv -f UTF-8 -t ISO8859-1 >expect &&
30 LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Hello World!" >actual &&
31 test_cmp expect actual
32'
33
9b9f46f5
JH
34test_expect_success GETTEXT_ISO_LOCALE 'gettext: impossible ISO-8859-1 output' '
35 LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "$MSGKEY" >runes &&
36 case "$(cat runes)" in
37 "$MSGKEY")
38 say "Your system gives back the key to message catalog"
39 ;;
40 "$PUNTS")
41 say "Your system replaces an impossible character with ?"
42 ;;
43 "$RUNES")
44 say "Your system gives back the raw message for an impossible request"
45 ;;
46 *)
47 say "We never saw the error behaviour your system exhibits"
48 false
49 ;;
50 esac
5e9637c6
ÆAB
51'
52
53test_expect_success GETTEXT_LOCALE 'gettext: Fetching a UTF-8 msgid -> UTF-8' '
54 printf "TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir" >expect &&
55 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: ‘single’ and “double” quotes" >actual &&
56 test_cmp expect actual
57'
58
59# How these quotes get transliterated depends on the gettext implementation:
60#
61# Debian: ,einfaldar' og ,,tvöfaldar" [GNU libintl]
62# FreeBSD: `einfaldar` og "tvöfaldar" [GNU libintl]
63# Solaris: ?einfaldar? og ?tvöfaldar? [Solaris libintl]
64#
65# Just make sure the contents are transliterated, and don't use grep -q
66# so that these differences are emitted under --verbose for curious
67# eyes.
68test_expect_success GETTEXT_ISO_LOCALE 'gettext: Fetching a UTF-8 msgid -> ISO-8859-1' '
69 LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: ‘single’ and “double” quotes" >actual &&
70 grep "einfaldar" actual &&
71 grep "$(echo tvöfaldar | iconv -f UTF-8 -t ISO8859-1)" actual
72'
73
74test_expect_success GETTEXT_LOCALE 'gettext.c: git init UTF-8 -> UTF-8' '
75 printf "Bjó til tóma Git lind" >expect &&
76 LANGUAGE=is LC_ALL="$is_IS_locale" git init repo >actual &&
77 test_when_finished "rm -rf repo" &&
78 grep "^$(cat expect) " actual
79'
80
81test_expect_success GETTEXT_ISO_LOCALE 'gettext.c: git init UTF-8 -> ISO-8859-1' '
82 printf "Bjó til tóma Git lind" >expect &&
83 LANGUAGE=is LC_ALL="$is_IS_iso_locale" git init repo >actual &&
84 test_when_finished "rm -rf repo" &&
74615c2a 85 grep "^$(iconv -f UTF-8 -t ISO8859-1 <expect) " actual
5e9637c6
ÆAB
86'
87
88test_done