Add more AFPercent_Format() tests.

- Small input values.
- Large nDec values.

Change-Id: I5e8413fe32f9c6764ec2daef85c1572a0404c651
Reviewed-on: https://pdfium-review.googlesource.com/c/51074
Reviewed-by: Wei Li <weili@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/testing/resources/javascript/public_methods.in b/testing/resources/javascript/public_methods.in
index 1c9eaca..6dca181 100644
--- a/testing/resources/javascript/public_methods.in
+++ b/testing/resources/javascript/public_methods.in
@@ -419,6 +419,28 @@
       expectEventValue(987654321, "AFPercent_Format(10, 3)", "98765432100,0000000000%");
       expectEventValue(987654321, "AFPercent_Format(10, 4)", "98'765'432'100.0000000000%");
 
+      expectEventValue(0.01, "AFPercent_Format(1, 0)", "1.0%");
+      expectEventValue(0.001, "AFPercent_Format(1, 0)", "0.1%");
+      expectEventValue(0.0001, "AFPercent_Format(1, 0)", "0.0%");
+      expectEventValue(0.00001, "AFPercent_Format(1, 0)", "0.0%");
+      expectEventValue(0.000001, "AFPercent_Format(1, 0)", "0.0%");
+      expectEventValue(0.000001, "AFPercent_Format(10, 2)", "0,0001000000%");
+
+      // Acrobat behaves strangely with smaller values.
+      // expectEventValue(0.0000001, "AFPercent_Format(1, 0)", "-170.0%");
+      // expectEventValue(0.00000001, "AFPercent_Format(1, 0)", "-180.0%");
+
+      // Inconsistent with PDFium due to bug 138.
+      // expectEventValue(0, "AFPercent_Format(20, 0)", "0.00000000000000000000%");
+      // expectEventValue(0, "AFPercent_Format(308, 0)", "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%");
+      // Acrobat starts failing here.
+      // expectEventValue(0, "AFPercent_Format(309, 0)", "-1.#IND000...000%");
+
+      // Inconsistent with PDFium due to bug 138.
+      // expectEventValue(0.000001, "AFPercent_Format(308, 0)", "0.00009999999999999999123964644631712417321978136897087097167968750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%");
+      // After 512, Acrobat probably ran out of buffer space.
+      // expectEventValue(0, "AFPercent_Format(513, 0)", "%");
+
       app.alert("**********************");
 
       expectError('', "AFPercent_Keystroke()");
diff --git a/testing/resources/javascript/public_methods_expected.txt b/testing/resources/javascript/public_methods_expected.txt
index c9edac0..07cac56 100644
--- a/testing/resources/javascript/public_methods_expected.txt
+++ b/testing/resources/javascript/public_methods_expected.txt
@@ -218,6 +218,12 @@
 Alert: PASS: AFPercent_Format(10, 2) = 98.765.432.100,0000000000%
 Alert: PASS: AFPercent_Format(10, 3) = 98765432100,0000000000%
 Alert: PASS: AFPercent_Format(10, 4) = 98'765'432'100.0000000000%
+Alert: PASS: AFPercent_Format(1, 0) = 1.0%
+Alert: PASS: AFPercent_Format(1, 0) = 0.1%
+Alert: PASS: AFPercent_Format(1, 0) = 0.0%
+Alert: PASS: AFPercent_Format(1, 0) = 0.0%
+Alert: PASS: AFPercent_Format(1, 0) = 0.0%
+Alert: PASS: AFPercent_Format(10, 2) = 0,0001000000%
 Alert: **********************
 Alert: PASS: AFPercent_Keystroke() threw AFPercent_Keystroke: Incorrect number of parameters passed to function.
 Alert: PASS: AFPercent_Keystroke(1) threw AFPercent_Keystroke: Incorrect number of parameters passed to function.