1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
# Regina - A Normal Surface Theory Calculator
# Python Test Suite Component
#
# Copyright (c) 2007-2009, Ben Burton
# For further details contact Ben Burton (bab@debian.org).
#
# Tests for UTF-8 character encodings when loading and importing files
#
# This file is a single component of Regina's python test suite. To run
# the python test suite, move to the main python directory in the source
# tree and run "make check".
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
# Fetch the python/testsuite path in the source tree, since we will need
# to access external files.
import sys
if (len(sys.argv) > 1):
testpath = sys.argv[1]
else:
testpath = '.'
# Make sure we get the transition between LATIN1 and UTF-8 regimes correct.
oldVersions = [ '0', '01', '1', '2', '3', '4',
'0.0', '0.1', '0.4', '0.5', '0.9', '0.10',
'1.0', '1.1', '1.4', '1.5', '1.9', '1.10',
'2.0', '2.1', '2.4', '2.5', '2.9', '2.10',
'3.0', '3.1', '3.4', '3.5', '3.9', '3.10',
'4.0', '4.01', '4.1', '4.2', '4.3', '4.4', '4.4.1', '4.4.9' ]
newVersions = [ '', '5', '6', '7', '8', '9', '10', '20', '30', '40', '50', '90',
'4.5', '4.6', '4.9', '4.10', '4.20', '4.30', '4.40', '4.50', '4.90',
'5.0', '5.1', '5.4', '5.5', '5.9', '9.1', '9.9', '10.1', '10.9',
'40.1', '40.9', '50.1', '50.9' ]
suffixes = [ '', 'a', 'alpha', '.', '.0', '.01', '.0.1', '.1',
'+a', '-a', '-0', '-1', '-9', '-10' ]
for v in oldVersions:
for s in suffixes:
if regina.versionUsesUTF8(v + s):
print 'ERROR: Version ' + v + s + ' claims to use UTF-8.'
for v in newVersions:
for s in suffixes:
if not regina.versionUsesUTF8(v + s):
print 'ERROR: Version ' + v + s + ' does not claim to use UTF-8.'
# Load a file created by an old version of regina. This file stores it
# strings as LATIN1, which should be converted to UTF-8 on import.
i18nOld = regina.readFileMagic(testpath + '/i18n-latin1.rga')
if i18nOld != None:
print i18nOld.getPacketLabel()
print i18nOld.getText()
# Load a version of the same file created by a newer version of Regina,
# which stores strings directly in UTF-8.
i18nNew = regina.readFileMagic(testpath + '/i18n-utf8.rga')
if i18nNew != None:
print i18nNew.getPacketLabel()
print i18nNew.getText()
# Import a triangulation from SnapPea that uses a subscript character in
# the triangulation name.
subscriptImport = regina.readSnapPea(testpath + '/O2_1.tri')
if subscriptImport != None:
print subscriptImport.getPacketLabel()
# Load a Regina data file with a pre-saved version of this same SnapPea
# triangulation.
subscriptLoad = regina.readFileMagic(testpath + '/O2_1.rga')
if subscriptLoad != None:
print subscriptLoad.getFirstTreeChild().getPacketLabel()
|