reftable/record: decode keys in place
[alt-git.git] / t / t0204-gettext-reencode-sanity.sh
blob4f2e0dcb02bda84409789b54f33237798c8f7e19
1 #!/bin/sh
3 # Copyright (c) 2010 Ævar Arnfjörð Bjarmason
6 test_description="Gettext reencoding of our *.po/*.mo files works"
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./lib-gettext.sh
11 # The constants used in a tricky observation for undefined behaviour
12 RUNES="TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ"
13 PUNTS="TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????"
14 MSGKEY="TEST: Old English Runes"
16 test_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
22 test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Runes' '
23 printf "%s" "$RUNES" >expect &&
24 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "$MSGKEY" >actual &&
25 test_cmp expect actual
28 test_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
34 test_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"
40 "$PUNTS")
41 say "Your system replaces an impossible character with ?"
43 "$RUNES")
44 say "Your system gives back the raw message for an impossible request"
47 say "We never saw the error behaviour your system exhibits"
48 false
50 esac
53 test_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
59 # How these quotes get transliterated depends on the gettext implementation:
61 # Debian: ,einfaldar' og ,,tvöfaldar" [GNU libintl]
62 # FreeBSD: `einfaldar` og "tvöfaldar" [GNU libintl]
63 # Solaris: ?einfaldar? og ?tvöfaldar? [Solaris libintl]
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.
68 test_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
74 test_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
81 test_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" &&
85 grep "^$(cat expect | iconv -f UTF-8 -t ISO8859-1) " actual
88 test_done