comparison test/file-encoding/file-encoding.tst @ 31144:f125ddb46055

dir_encoding: Use encoding from .oct-config file in current directory (bug #62761). * libinterp/corefcn/load-path.cc (load_path::read_dir_config), libinterp/corefcn/input.cc (input_system::dir_encoding): Use canonicalized path as key for the dir_encoding map. * test/file-encoding: Add tests for this feature. * test/Makefile.am: Add new folder to test suite.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 13 Jul 2022 13:20:48 +0200
parents
children 7d4cf04665e6
comparison
equal deleted inserted replaced
31143:52b8b0c1baf9 31144:f125ddb46055
1 ########################################################################
2 ##
3 ## Copyright (C) 2022 The Octave Project Developers
4 ##
5 ## See the file COPYRIGHT.md in the top-level directory of this
6 ## distribution or <https://octave.org/copyright/>.
7 ##
8 ## This file is part of Octave.
9 ##
10 ## Octave is free software: you can redistribute it and/or modify it
11 ## under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation, either version 3 of the License, or
13 ## (at your option) any later version.
14 ##
15 ## Octave is distributed in the hope that it will be useful, but
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
19 ##
20 ## You should have received a copy of the GNU General Public License
21 ## along with Octave; see the file COPYING. If not, see
22 ## <https://www.gnu.org/licenses/>.
23 ##
24 ########################################################################
25
26 ## test file in current directory
27
28 %!assert (dir_encoding ("."), "windows-1252")
29 %!assert (dir_encoding (pwd ()), "windows-1252")
30
31 %!test
32 %! help_str = get_help_text ("test_CP1252");
33 %! ## The help text contains the string "ÄÖÜäöü ŠŽšž". Compare to the
34 %! ## corresponding UTF-8 byte sequence to make sure this test is independent
35 %! ## of how this .tst file is interpreted.
36 %! ref_str = char ([195 132 195 150 195 156 195 164 195 182 195 188 32 ...
37 %! 197 160 197 189 197 161 197 190]);
38 %! assert (strfind (help_str, ref_str));
39
40
41 ## test file in load path (relative)
42
43 %!test
44 %! path_orig = path ();
45 %! unwind_protect
46 %! addpath ("CP1251");
47 %! assert (dir_encoding ("CP1251"), "windows-1251");
48 %! assert (dir_encoding (fullfile (pwd (), "CP1251")), "windows-1251");
49 %! unwind_protect_cleanup
50 %! path (path_orig);
51 %! end_unwind_protect
52
53 %!test
54 %! path_orig = path ();
55 %! unwind_protect
56 %! addpath ("CP1251");
57 %! help_str = get_help_text ("test_CP1251");
58 %! ## The help text contains the string "ДЦЬдць ЉЋљћ". Compare to the
59 %! ## corresponding UTF-8 byte sequence to make sure this test is independent
60 %! ## of how this .tst of how this .tst file is interpreted.
61 %! ref_str = char ([208 148 208 166 208 172 208 180 209 134 209 140 32 ...
62 %! 208 137 208 139 209 153 209 155]);
63 %! assert (strfind (help_str, ref_str));
64 %! unwind_protect_cleanup
65 %! path (path_orig);
66 %! end_unwind_protect
67
68
69 ## test file in load path (absolute)
70
71 %!test
72 %! clear all; # make sure files are re-parsed
73 %! path_orig = path ();
74 %! unwind_protect
75 %! new_path = canonicalize_file_name ("CP1251");
76 %! addpath (new_path);
77 %! assert (dir_encoding (new_path), "windows-1251");
78 %! assert (dir_encoding ("CP1251"), "windows-1251");
79 %! assert (dir_encoding (fullfile (pwd (), "CP1251")), "windows-1251");
80 %! unwind_protect_cleanup
81 %! path (path_orig);
82 %! end_unwind_protect
83
84 %!test
85 %! clear all; # make sure files are re-parsed
86 %! path_orig = path ();
87 %! unwind_protect
88 %! addpath (canonicalize_file_name ("CP1251"));
89 %! help_str = get_help_text ("test_CP1251");
90 %! ## The help text contains the string "ДЦЬдць ЉЋљћ". Compare to the UTF-8
91 %! ## byte sequence to make sure this test is independent of how this .tst
92 %! ## file is interpreted.
93 %! ref_str = char ([208 148 208 166 208 172 208 180 209 134 209 140 32 ...
94 %! 208 137 208 139 209 153 209 155]);
95 %! assert (strfind (help_str, ref_str));
96 %! unwind_protect_cleanup
97 %! path (path_orig);
98 %! end_unwind_protect
99