Mercurial > hg > soundsoftware-site
comparison test/unit/helpers/repository_helper_test.rb @ 245:051f544170fe
* Update to SVN trunk revision 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 11:42:28 +0000 |
parents | |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
244:8972b600f4fb | 245:051f544170fe |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../../test_helper', __FILE__) | |
19 | |
20 class RepositoryHelperTest < HelperTestCase | |
21 include RepositoriesHelper | |
22 | |
23 def test_from_latin1_to_utf8 | |
24 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
25 s1 = "Texte encod\xc3\xa9" | |
26 s2 = "Texte encod\xe9" | |
27 s3 = s2 | |
28 if s1.respond_to?(:force_encoding) | |
29 s1.force_encoding("UTF-8") | |
30 s2.force_encoding("ASCII-8BIT") | |
31 s3.force_encoding("UTF-8") | |
32 end | |
33 assert_equal s1, to_utf8(s2) | |
34 assert_equal s1, to_utf8(s3) | |
35 end | |
36 end | |
37 | |
38 def test_from_euc_jp_to_utf8 | |
39 with_settings :repositories_encodings => 'UTF-8,EUC-JP' do | |
40 s1 = "\xe3\x83\xac\xe3\x83\x83\xe3\x83\x89\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\xb3" | |
41 s2 = "\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3" | |
42 s3 = s2 | |
43 if s1.respond_to?(:force_encoding) | |
44 s1.force_encoding("UTF-8") | |
45 s2.force_encoding("ASCII-8BIT") | |
46 s3.force_encoding("UTF-8") | |
47 end | |
48 assert_equal s1, to_utf8(s2) | |
49 assert_equal s1, to_utf8(s3) | |
50 end | |
51 end | |
52 | |
53 def test_to_utf8_should_be_converted_all_latin1_to_utf8 | |
54 with_settings :repositories_encodings => 'ISO-8859-1' do | |
55 s1 = "\xc3\x82\xc2\x80" | |
56 s2 = "\xC2\x80" | |
57 s3 = s2 | |
58 if s1.respond_to?(:force_encoding) | |
59 s1.force_encoding("UTF-8") | |
60 s2.force_encoding("ASCII-8BIT") | |
61 s3.force_encoding("UTF-8") | |
62 end | |
63 assert_equal s1, to_utf8(s2) | |
64 assert_equal s1, to_utf8(s3) | |
65 end | |
66 end | |
67 end | |
68 |