Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: testing/resources/javascript/util_bytetochar.in

Issue 1838543002: Add test for util.byteToChar() and fix error msg. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: static cast. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/javascript/util.cpp ('k') | testing/resources/javascript/util_bytetochar_expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {{header}} 1 {{header}}
2 {{object 1 0}} << 2 {{object 1 0}} <<
3 /Type /Catalog 3 /Type /Catalog
4 /Pages 2 0 R 4 /Pages 2 0 R
5 /OpenAction 10 0 R 5 /OpenAction 10 0 R
6 >> 6 >>
7 endobj 7 endobj
8 {{object 2 0}} << 8 {{object 2 0}} <<
9 /Type /Pages 9 /Type /Pages
10 /Count 1 10 /Count 1
(...skipping 16 matching lines...) Expand all
27 {{object 10 0}} << 27 {{object 10 0}} <<
28 /Type /Action 28 /Type /Action
29 /S /JavaScript 29 /S /JavaScript
30 /JS 11 0 R 30 /JS 11 0 R
31 >> 31 >>
32 endobj 32 endobj
33 % JS program to exexute 33 % JS program to exexute
34 {{object 11 0}} << 34 {{object 11 0}} <<
35 >> 35 >>
36 stream 36 stream
37 app.alert('Applying to util itself - should succeed'); 37 function TestOneInput(x) {
38 try {
39 var s = util.byteToChar(x);
40 if (s.length) {
41 s = s.charCodeAt(0);
42 }
43 app.alert(x + " => " + s);
44 }
45 catch (e) {
46 app.alert(x + ": Caught error: " + e);
47 }
48 }
49 TestOneInput(0);
50 TestOneInput(65);
51 TestOneInput(127);
52 TestOneInput(128);
53 TestOneInput(255);
54 TestOneInput(256);
55 TestOneInput(40000000);
56 TestOneInput(-1);
38 try { 57 try {
39 app.alert(util.byteToChar.apply(util, [65])); 58 util.byteToChar();
40 } 59 }
41 catch (e) { 60 catch (e) {
42 app.alert('Caught: ' + e); 61 app.alert("Caught expected error: " + e);
43 } 62 }
44
45 app.alert('Applying to array - should throw');
46 try { 63 try {
47 app.alert(util.byteToChar.apply([], [65])); 64 util.byteToChar({x:39});
48 } 65 }
49 catch (e) { 66 catch (e) {
50 app.alert('Caught: ' + e); 67 app.alert("Caught expected error: " + e);
51 }
52
53 app.alert('Applying to number - should throw');
54 try {
55 app.alert(util.byteToChar.apply(7, [65]));
56 }
57 catch (e) {
58 app.alert('Caught: ' + e);
59 }
60
61 app.alert('Applying to wrong native obj - should throw');
62 try {
63 app.alert(util.byteToChar.apply(app, [65]));
64 }
65 catch (e) {
66 app.alert('Caught: ' + e);
67 } 68 }
68 endstream 69 endstream
69 endobj 70 endobj
70 {{xref}} 71 {{xref}}
71 trailer << 72 trailer <<
72 /Root 1 0 R 73 /Root 1 0 R
73 >> 74 >>
74 {{startxref}} 75 {{startxref}}
75 %%EOF 76 %%EOF
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/util.cpp ('k') | testing/resources/javascript/util_bytetochar_expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698