summaryrefslogtreecommitdiffstats
path: root/src/testdir
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/Make_all.mak6
-rw-r--r--src/testdir/ru_RU/LC_MESSAGES/__PACKAGE__.mobin0 -> 875 bytes
-rw-r--r--src/testdir/test_functions.vim5
-rw-r--r--src/testdir/test_gettext.vim16
-rw-r--r--src/testdir/test_gettext_cp1251.vim22
-rw-r--r--src/testdir/test_gettext_utf8.vim22
6 files changed, 66 insertions, 5 deletions
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index e31d2b5f3e..a49f158757 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -161,6 +161,9 @@ NEW_TESTS = \
test_function_lists \
test_ga \
test_getcwd \
+ test_gettext \
+ test_gettext_cp1251 \
+ test_gettext_utf8 \
test_getvar \
test_gf \
test_glob2regpat \
@@ -420,6 +423,9 @@ NEW_TESTS_RES = \
test_functions.res \
test_function_lists.res \
test_getcwd.res \
+ test_gettext.res \
+ test_gettext_cp1251.res \
+ test_gettext_utf8.res \
test_getvar.res \
test_gf.res \
test_gn.res \
diff --git a/src/testdir/ru_RU/LC_MESSAGES/__PACKAGE__.mo b/src/testdir/ru_RU/LC_MESSAGES/__PACKAGE__.mo
new file mode 100644
index 0000000000..300eba2137
--- /dev/null
+++ b/src/testdir/ru_RU/LC_MESSAGES/__PACKAGE__.mo
Binary files differ
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index ba8f18fa5a..8e973f6c9e 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -3865,11 +3865,6 @@ func Test_default_arg_value()
call assert_equal('msg', HasDefault())
endfunc
-" Test for gettext()
-func Test_gettext()
- call assert_fails('call gettext(1)', 'E1174:')
-endfunc
-
func Test_builtin_check()
call assert_fails('let g:["trim"] = {x -> " " .. x}', 'E704:')
call assert_fails('let g:.trim = {x -> " " .. x}', 'E704:')
diff --git a/src/testdir/test_gettext.vim b/src/testdir/test_gettext.vim
new file mode 100644
index 0000000000..6a5aafdfe2
--- /dev/null
+++ b/src/testdir/test_gettext.vim
@@ -0,0 +1,16 @@
+source check.vim
+
+" Test for gettext()
+func Test_gettext()
+ call assert_fails('call bindtextdomain("test")', 'E119:')
+ call assert_fails('call bindtextdomain("vim", "test")', 'E475:')
+
+ call assert_fails('call gettext(1)', 'E1174:')
+ call assert_equal('xxxTESTxxx', gettext("xxxTESTxxx"))
+
+ call assert_equal('xxxTESTxxx', gettext("xxxTESTxxx", "vim"))
+ call assert_equal('xxxTESTxxx', gettext("xxxTESTxxx", "__PACKAGE__"))
+ call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_gettext_cp1251.vim b/src/testdir/test_gettext_cp1251.vim
new file mode 100644
index 0000000000..fe02a03fc5
--- /dev/null
+++ b/src/testdir/test_gettext_cp1251.vim
@@ -0,0 +1,22 @@
+source check.vim
+
+" Test for gettext()
+func Test_gettext()
+ set encoding=cp1251
+ call bindtextdomain("__PACKAGE__", getcwd())
+ try
+ language ru_RU
+ call assert_equal(': ', gettext("ERROR: ", "__PACKAGE__"))
+ catch /^Vim\%((\a\+)\)\=:E197:/
+ throw "Skipped: not possible to set locale to ru (missing?)"
+ endtry
+ try
+ language en_GB.UTF-8
+ call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
+ catch /^Vim\%((\a\+)\)\=:E197:/
+ throw "Skipped: not possible to set locale to en (missing?)"
+ endtry
+ set encoding&
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_gettext_utf8.vim b/src/testdir/test_gettext_utf8.vim
new file mode 100644
index 0000000000..277710e14d
--- /dev/null
+++ b/src/testdir/test_gettext_utf8.vim
@@ -0,0 +1,22 @@
+source check.vim
+
+" Test for gettext()
+func Test_gettext()
+ set encoding=utf-8
+ call bindtextdomain("__PACKAGE__", getcwd())
+ try
+ language ru_RU
+ call assert_equal('ОШИБКА: ', gettext("ERROR: ", "__PACKAGE__"))
+ catch /^Vim\%((\a\+)\)\=:E197:/
+ throw "Skipped: not possible to set locale to ru (missing?)"
+ endtry
+ try
+ language en_GB.UTF-8
+ call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__"))
+ catch /^Vim\%((\a\+)\)\=:E197:/
+ throw "Skipped: not possible to set locale to en (missing?)"
+ endtry
+ set encoding&
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab