Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big5 encoding and decoding tests #3197

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 55 additions & 0 deletions encoding/legacy-mb-tchinese/big5/big5-decode-big5-hkscs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8"/>
<title>big5-hkscs decoding</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org">
<link rel="help" href="https://encoding.spec.whatwg.org/#names-and-labels">
<meta name="assert" content="The browser produces the same decoding behavior for a document labeled 'big5-hkscs' as for a document labeled 'big5'.">
<style>
iframe { display:none }
form { display:none }
</style>
<script src="big5_index.js"></script>
<script src="big5-decoder.js"></script>
</head>

<body onload="showNodes();">

<iframe src="big5_chars-big5-hkscs.html" name="scriptWindow" id="scrwin"></iframe>

<p class="instructions">Test passes if the number of failures is the same as for test big5-decode.html</p>
<div id="log"></div>

<script>
var tests = []

function iframeRef( frameRef ) {
return frameRef.contentWindow
? frameRef.contentWindow.document
: frameRef.contentDocument
}

function showNodes () {
var iframe = iframeRef( document.getElementById('scrwin') );
nodes = iframe.querySelectorAll('span')

for (var i=0; i<nodes.length; i++) {
tests[i] = async_test("U+"+nodes[i].dataset.cp+' '+String.fromCodePoint(parseInt(nodes[i].dataset.cp,16))+' '+big5Decoder(nodes[i].dataset.bytes)+' '+nodes[i].dataset.bytes)
}

for (var i=0; i<nodes.length; i++) {
tests[i].step(function() {assert_equals(nodes[i].textContent, big5Decoder(nodes[i].dataset.bytes)) } )
tests[i].done()
}
}


</script>
<p style="font-size: 70%;">You can raise issues with this test at <a target="_blank" href="https://github.com/w3c/encodingtests/issues">https://github.com/w3c/encodingtests/issues</a></p>
</body>
</html>


55 changes: 55 additions & 0 deletions encoding/legacy-mb-tchinese/big5/big5-decode-cn-big5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8"/>
<title>cn-big5 decoding</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org">
<link rel="help" href="https://encoding.spec.whatwg.org/#names-and-labels">
<meta name="assert" content="The browser produces the same decoding behavior for a document labeled 'cn-big5' as for a document labeled 'big5'.">
<style>
iframe { display:none }
form { display:none }
</style>
<script src="big5_index.js"></script>
<script src="big5-decoder.js"></script>
</head>

<body onload="showNodes();">

<iframe src="big5_chars-cn-big5.html" name="scriptWindow" id="scrwin"></iframe>

<p class="instructions">Test passes if the number of failures is the same as for test big5-decode.html</p>
<div id="log"></div>

<script>
var tests = []

function iframeRef( frameRef ) {
return frameRef.contentWindow
? frameRef.contentWindow.document
: frameRef.contentDocument
}

function showNodes () {
var iframe = iframeRef( document.getElementById('scrwin') );
nodes = iframe.querySelectorAll('span')

for (var i=0; i<nodes.length; i++) {
tests[i] = async_test("U+"+nodes[i].dataset.cp+' '+String.fromCodePoint(parseInt(nodes[i].dataset.cp,16))+' '+big5Decoder(nodes[i].dataset.bytes)+' '+nodes[i].dataset.bytes)
}

for (var i=0; i<nodes.length; i++) {
tests[i].step(function() {assert_equals(nodes[i].textContent, big5Decoder(nodes[i].dataset.bytes)) } )
tests[i].done()
}
}


</script>
<p style="font-size: 70%;">You can raise issues with this test at <a target="_blank" href="https://github.com/w3c/encodingtests/issues">https://github.com/w3c/encodingtests/issues</a></p>
</body>
</html>


55 changes: 55 additions & 0 deletions encoding/legacy-mb-tchinese/big5/big5-decode-csbig5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8"/>
<title>csbig5 decoding</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org">
<link rel="help" href="https://encoding.spec.whatwg.org/#names-and-labels">
<meta name="assert" content="The browser produces the same decoding behavior for a document labeled 'csbig5' as for a document labeled 'big5'.">
<style>
iframe { display:none }
form { display:none }
</style>
<script src="big5_index.js"></script>
<script src="big5-decoder.js"></script>
</head>

<body onload="showNodes();">

<iframe src="big5_chars-csbig5.html" name="scriptWindow" id="scrwin"></iframe>

<p class="instructions">Test passes if the number of failures is the same as for test big5-decode.html</p>
<div id="log"></div>

<script>
var tests = []

function iframeRef( frameRef ) {
return frameRef.contentWindow
? frameRef.contentWindow.document
: frameRef.contentDocument
}

function showNodes () {
var iframe = iframeRef( document.getElementById('scrwin') );
nodes = iframe.querySelectorAll('span')

for (var i=0; i<nodes.length; i++) {
tests[i] = async_test("U+"+nodes[i].dataset.cp+' '+String.fromCodePoint(parseInt(nodes[i].dataset.cp,16))+' '+big5Decoder(nodes[i].dataset.bytes)+' '+nodes[i].dataset.bytes)
}

for (var i=0; i<nodes.length; i++) {
tests[i].step(function() {assert_equals(nodes[i].textContent, big5Decoder(nodes[i].dataset.bytes)) } )
tests[i].done()
}
}


</script>
<p style="font-size: 70%;">You can raise issues with this test at <a target="_blank" href="https://github.com/w3c/encodingtests/issues">https://github.com/w3c/encodingtests/issues</a></p>
</body>
</html>


74 changes: 74 additions & 0 deletions encoding/legacy-mb-tchinese/big5/big5-decode-errors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8"/>
<title>Big5 decoding errors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org">
<link rel="help" href="http://www.w3.org/TR/encoding/#big5">
<meta name="assert" content="The browser decodes characters that are not recognised from the big5 encoding as replacement characters.">
<style>
iframe { display:none }
</style>
</head>

<body onload="showNodes();">

<iframe src="big5_errors.html" name="scriptWindow" id="scrwin"></iframe>

<div id="log"></div>

<script>
var tests = []

function iframeRef( frameRef ) {
return frameRef.contentWindow
? frameRef.contentWindow.document
: frameRef.contentDocument
}

function showNodes () {
var iframe = iframeRef( document.getElementById('scrwin') )
nodes = iframe.querySelectorAll('span')

t=-1;
t++; tests[t] = async_test("lead not 0x00 and no more bytes: AB")
t++; tests[t] = async_test("lead not 0x00 and no more bytes: AB B5 AB")
t++; tests[t] = async_test("lead not 0x00 and no more bytes: AB AB AB")

t++; tests[t] = async_test("lead byte outside 0x81-0xFE: FF")
t++; tests[t] = async_test("lead byte outside 0x81-0xFE: AB AB FF")

t++; tests[t] = async_test("trail byte outside 0x41-0xFE: AB 31")
t++; tests[t] = async_test("trail byte outside 0x41-0xFE: AB FF")

t++; tests[t] = async_test("pointer is null: C8 F2")



t=-1;
t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '�') } )
tests[t].done()
t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '奏�') } )
tests[t].done()
t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '垂�') } )
tests[t].done()
t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '�') } )
tests[t].done()
t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '奏�') } )
tests[t].done()
t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '�1') } )
tests[t].done()
t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '�') } )
tests[t].done()
t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '�') } )
tests[t].done()

}

</script>
<p style="font-size: 70%;">You can raise issues with this test at <a target="_blank" href="https://github.com/w3c/encodingtests/issues">https://github.com/w3c/encodingtests/issues</a></p>
</body>
</html>

54 changes: 54 additions & 0 deletions encoding/legacy-mb-tchinese/big5/big5-decode-extra.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8"/>
<title>Big5 decoding (extra)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org">
<link rel="help" href="http://www.w3.org/TR/encoding/#big5">
<meta name="assert" content="The browser decodes all characters as expected from a file generated by encoding all pointers less than 5024 in the big5 encoding per the encoder steps in the specification.">
<style>
iframe { display:none }
form { display:none }
</style>
<script src="big5_index.js"></script>
<script src="big5-decoder.js"></script>
</head>

<body onload="showNodes();">

<iframe src="big5_chars_extra.html" name="scriptWindow" id="scrwin"></iframe>

<div id="log"></div>

<script>
var tests = []

function iframeRef( frameRef ) {
return frameRef.contentWindow
? frameRef.contentWindow.document
: frameRef.contentDocument
}

function showNodes () {
var iframe = iframeRef( document.getElementById('scrwin') );
nodes = iframe.querySelectorAll('span')

for (var i=0; i<nodes.length; i++) {
tests[i] = async_test("U+"+nodes[i].dataset.cp+' '+String.fromCodePoint(parseInt(nodes[i].dataset.cp,16))+' '+big5Decoder(nodes[i].dataset.bytes)+' '+nodes[i].dataset.bytes)
}

for (var i=0; i<nodes.length; i++) {
tests[i].step(function() {assert_equals(nodes[i].textContent, big5Decoder(nodes[i].dataset.bytes)) } )
tests[i].done()
}
}


</script>
<p style="font-size: 70%;">You can raise issues with this test at <a target="_blank" href="https://github.com/w3c/encodingtests/issues">https://github.com/w3c/encodingtests/issues</a></p>
</body>
</html>


55 changes: 55 additions & 0 deletions encoding/legacy-mb-tchinese/big5/big5-decode-x-x-big5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8"/>
<title>x-x-big5 decoding</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org">
<link rel="help" href="https://encoding.spec.whatwg.org/#names-and-labels">
<meta name="assert" content="The browser produces the same decoding behavior for a document labeled 'x-x-big5' as for a document labeled 'big5'.">
<style>
iframe { display:none }
form { display:none }
</style>
<script src="big5_index.js"></script>
<script src="big5-decoder.js"></script>
</head>

<body onload="showNodes();">

<iframe src="big5_chars-x-x-big5.html" name="scriptWindow" id="scrwin"></iframe>

<p class="instructions">Test passes if the number of failures is the same as for test big5-decode.html</p>
<div id="log"></div>

<script>
var tests = []

function iframeRef( frameRef ) {
return frameRef.contentWindow
? frameRef.contentWindow.document
: frameRef.contentDocument
}

function showNodes () {
var iframe = iframeRef( document.getElementById('scrwin') );
nodes = iframe.querySelectorAll('span')

for (var i=0; i<nodes.length; i++) {
tests[i] = async_test("U+"+nodes[i].dataset.cp+' '+String.fromCodePoint(parseInt(nodes[i].dataset.cp,16))+' '+big5Decoder(nodes[i].dataset.bytes)+' '+nodes[i].dataset.bytes)
}

for (var i=0; i<nodes.length; i++) {
tests[i].step(function() {assert_equals(nodes[i].textContent, big5Decoder(nodes[i].dataset.bytes)) } )
tests[i].done()
}
}


</script>
<p style="font-size: 70%;">You can raise issues with this test at <a target="_blank" href="https://github.com/w3c/encodingtests/issues">https://github.com/w3c/encodingtests/issues</a></p>
</body>
</html>