[Pkg-javascript-commits] [sockjs-client] 185/434: Introduce first go of utf encoding tests.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 584379baab791e94ac5a5c5e1cde65bb61e09a5b
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Tue Oct 25 19:52:07 2011 +0100

    Introduce first go of utf encoding tests.
    
    It's still quite rough but with a bit of luck will evolve into something complete.
---
 tests/html/src/tests.coffee | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
index aa1f865..3701e0b 100644
--- a/tests/html/src/tests.coffee
+++ b/tests/html/src/tests.coffee
@@ -21,6 +21,12 @@ echo_factory_factory = (protocol, messages) ->
             r.send(a[0])
         r.onmessage = (e) ->
             #log('onmessage ' + e);
+            x = ''+a[0]
+            if e.data != x
+                for i in [0...e.data.length]
+                    if e.data.charCodeAt(i) != x.charCodeAt(i)
+                        #console.log('source: ' + x.charCodeAt(i) + ' differs from: ' + e.data.charCodeAt(i))
+                        true
             equal(e.data, '' + a[0])
             a.shift()
             if typeof a[0] is 'undefined'
@@ -200,6 +206,21 @@ factor_batch_large_amp = (protocol) ->
     return batch_factory_factory_amp(protocol, messages)
 
 
+factor_echo_utf_encoding = (protocol) ->
+    message = for i in [0..65535] by 64
+                if i is 0x340 # chromium during xhr converts \u0340 to \u0300
+                    continue
+                if i is 0x2000  # again, chrome xhr
+                    continue
+                # ignore surrogates
+                # http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters#Surrogates
+                if i >= 0xD800 and i <= 0xDFFF
+                    continue
+                if i >= 62100 and i <= 65472 # again, chrome
+                    continue
+                String.fromCharCode(i)
+    return echo_factory_factory(protocol, [message.join('')])
+
 
 factor_user_close = (protocol) ->
     return ->
@@ -300,6 +321,7 @@ test_protocol_messages = (protocol) ->
         asyncTest("echo1", factor_echo_basic(protocol))
         asyncTest("echo2", factor_echo_rich(protocol))
         asyncTest("unicode", factor_echo_unicode(protocol))
+        asyncTest("utf encoding", factor_echo_utf_encoding(protocol))
         asyncTest("special_chars", factor_echo_special_chars(protocol))
         asyncTest("large message (ping-pong)",
             factor_echo_large_message(protocol))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list