tests: Fix tests with UCS-2 Python.
authorEthan Jackson <ethan@nicira.com>
Mon, 31 Jan 2011 04:02:16 +0000 (20:02 -0800)
committerEthan Jackson <ethan@nicira.com>
Mon, 31 Jan 2011 22:59:27 +0000 (14:59 -0800)
Python can be built with either UCS2 or UCS4 support.  When built
with UCS2 the python related surrogate pairs tests cannot pass.
This commit handles this situation more gracefully.

tests/json.at
tests/ovsdb-data.at

index 56329ed..3962da1 100644 (file)
@@ -19,6 +19,18 @@ m4_define([JSON_CHECK_POSITIVE_PY],
 ])
    AT_CLEANUP])
 
+m4_define([JSON_CHECK_POSITIVE_UCS4PY],
+  [AT_SETUP([$1])
+   AT_KEYWORDS([json positive Python])
+   AT_SKIP_IF([test $HAVE_PYTHON = no])
+   AT_XFAIL_IF([$PYTHON -c "exit(len(u'\U00010800'))"; test $? -ne 1])
+   AT_CHECK([printf %s "AS_ESCAPE([$2])" > input])
+   AT_CAPTURE_FILE([input])
+   AT_CHECK([$PYTHON $srcdir/test-json.py $4 input], [0], [stdout], [])
+   AT_CHECK([cat stdout], [0], [$3
+])
+   AT_CLEANUP])
+
 m4_define([JSON_CHECK_POSITIVE],
   [JSON_CHECK_POSITIVE_C([$1 - C], [$2], [$3], [$4])
    JSON_CHECK_POSITIVE_PY([$1 - Python], [$2], [$3], [$4])])
@@ -75,7 +87,10 @@ JSON_CHECK_POSITIVE([escape sequences],
 JSON_CHECK_POSITIVE([Unicode escape sequences], 
   [[[ " \u0022 \u005c \u002F \u0008 \u000c \u000A \u000d \u0009" ]]],
   [[[" \" \\ / \b \f \n \r \t"]]])
-JSON_CHECK_POSITIVE([surrogate pairs],
+JSON_CHECK_POSITIVE_C([surrogate pairs - C],
+  [[["\ud834\udd1e"]]],
+  [[["𝄞"]]])
+JSON_CHECK_POSITIVE_UCS4PY([surrogate pairs - Python],
   [[["\ud834\udd1e"]]],
   [[["𝄞"]]])
 JSON_CHECK_NEGATIVE([a string by itself is not valid JSON], ["xxx"],
index 98e8108..9736961 100644 (file)
@@ -457,12 +457,12 @@ OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long],
     '["a"]' \
     '["ab"]' \
     '["abc"]' \
-    '["\ud834\udd1e"]']],
+    '["de"]']],
   [[""
 "a"
 "ab"
 constraint violation: "abc" length 3 is greater than maximum allowed length 2
-"𝄞"]])
+"de"]])
 
 AT_BANNER([OSVDB -- simple data])