diff options
author | Martin Pool <mbp@samba.org> | 2003-04-08 08:05:01 +0000 |
---|---|---|
committer | Martin Pool <mbp@samba.org> | 2003-04-08 08:05:01 +0000 |
commit | bce94d35f125eaeaa4db7866503418b8f281edf2 (patch) | |
tree | 0fd10466bf1b16f93f147bb9b5c2f8527580c6bf /source3/stf/strings.py | |
parent | 6cb4575b12ebb495883a6bf081ed17eccf641df4 (diff) | |
download | samba-bce94d35f125eaeaa4db7866503418b8f281edf2.tar.gz samba-bce94d35f125eaeaa4db7866503418b8f281edf2.tar.bz2 samba-bce94d35f125eaeaa4db7866503418b8f281edf2.zip |
Integrate abartlet's t_push_ucs2 test into test framework:
- Build t_push_ucs2 as part of check-programs, the prerequisite for
"make check".
- t_push_ucs2.c: Load configuration from /dev/null so that we get a
unix_charset of UTF-8 and can do meaningful UCS2 tests. Better
comment.
- Add a test to strings.py which tries conversion UTF8->UCS2->UTF8
and checks the results. Do this for English, Latin-1, and Katakana
strings.
- Add Python module with symbolic names for a handful of UNICODE
characters.
(This used to be commit 275e095c92ac74815ab9e388a0e83cdb7ddd85f3)
Diffstat (limited to 'source3/stf/strings.py')
-rwxr-xr-x | source3/stf/strings.py | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/source3/stf/strings.py b/source3/stf/strings.py index 8fc12d4e39..4e070c0444 100755 --- a/source3/stf/strings.py +++ b/source3/stf/strings.py @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python # Comfychair test cases for Samba string functions. @@ -19,7 +19,22 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +# XXX: All this code assumes that the Unix character set is UTF-8, +# which is the most common setting. I guess it would be better to +# force it to that value while running the tests. I'm not sure of the +# best way to do that yet. +# +# Note that this is NOT the case in C code until the loadparm table is +# intialized -- the default seems to be ASCII, which rather lets Samba +# off the hook. :-) The best way seems to be to put this in the test +# harnesses: +# +# lp_load("/dev/null", True, False, False); +# +# -- mbp + import sys, re, comfychair +from unicodenames import * def signum(a): if a < 0: @@ -28,6 +43,23 @@ def signum(a): return +1 else: return 0 + + +class PushUCS2_Tests(comfychair.TestCase): + """Conversion to/from UCS2""" + def runtest(self): + OE = LATIN_CAPITAL_LETTER_O_WITH_DIARESIS + oe = LATIN_CAPITAL_LETTER_O_WITH_DIARESIS + cases = ['hello', + 'hello world', + 'g' + OE + OE + 'gomobile', + 'g' + OE + oe + 'gomobile', + u'foo\u0100', + KATAKANA_LETTER_A * 20, + ] + for u8str in cases: + out, err = self.runcmd("t_push_ucs2 \"%s\"" % u8str.encode('utf-8')) + self.assert_equal(out, "0\n") class StrCaseCmp_Ascii_Tests(comfychair.TestCase): @@ -61,9 +93,13 @@ class StrCaseCmp_Ascii_Tests(comfychair.TestCase): self.run_strcmp(a, b, expect) # Define the tests exported by this module -tests = [StrCaseCmp_Ascii_Tests] +tests = [StrCaseCmp_Ascii_Tests, + PushUCS2_Tests] # Handle execution of this file as a main program if __name__ == '__main__': comfychair.main(tests) +# Local variables: +# coding: utf-8 +# End: |