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

Unified 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, 9 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/resources/javascript/util_bytetochar.in
diff --git a/testing/resources/javascript/apply.in b/testing/resources/javascript/util_bytetochar.in
similarity index 51%
copy from testing/resources/javascript/apply.in
copy to testing/resources/javascript/util_bytetochar.in
index 1342c1af4e71c86dfd01b091d0f9fbe68cebfe69..a9adfbccaf72a01349c5639c46afc42046bed7da 100644
--- a/testing/resources/javascript/apply.in
+++ b/testing/resources/javascript/util_bytetochar.in
@@ -34,36 +34,37 @@ endobj
{{object 11 0}} <<
>>
stream
-app.alert('Applying to util itself - should succeed');
-try {
- app.alert(util.byteToChar.apply(util, [65]));
-}
-catch (e) {
- app.alert('Caught: ' + e);
-}
-
-app.alert('Applying to array - should throw');
-try {
- app.alert(util.byteToChar.apply([], [65]));
-}
-catch (e) {
- app.alert('Caught: ' + e);
+function TestOneInput(x) {
+ try {
+ var s = util.byteToChar(x);
+ if (s.length) {
+ s = s.charCodeAt(0);
+ }
+ app.alert(x + " => " + s);
+ }
+ catch (e) {
+ app.alert(x + ": Caught error: " + e);
+ }
}
-
-app.alert('Applying to number - should throw');
+TestOneInput(0);
+TestOneInput(65);
+TestOneInput(127);
+TestOneInput(128);
+TestOneInput(255);
+TestOneInput(256);
+TestOneInput(40000000);
+TestOneInput(-1);
try {
- app.alert(util.byteToChar.apply(7, [65]));
+ util.byteToChar();
}
catch (e) {
- app.alert('Caught: ' + e);
+ app.alert("Caught expected error: " + e);
}
-
-app.alert('Applying to wrong native obj - should throw');
try {
- app.alert(util.byteToChar.apply(app, [65]));
+ util.byteToChar({x:39});
}
catch (e) {
- app.alert('Caught: ' + e);
+ app.alert("Caught expected error: " + e);
}
endstream
endobj
« 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