Skip to content

Commit 2779519

Browse files
committed
update Java version
1 parent 42d2304 commit 2779519

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/test/java/com/upokecenter/test/CBORObjectTest.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10034,7 +10034,8 @@ public static void TestParseNumberFxx(
1003410034
int f32,
1003510035
long f64,
1003610036
String line) {
10037-
if (str.charAt(0) == '.') {
10037+
if (str.charAt(0) == '.' || str.charAt(str.length() - 1) =='.' ||
10038+
str.contains(".e") || str.contains(".E")) {
1003810039
// Not a valid JSON number, so skip
1003910040
// System.out.println(str);
1004010041
return;
@@ -10067,6 +10068,35 @@ public static void TestParseNumberFxx(
1006710068
// TODO: Test f16
1006810069
}
1006910070

10071+
@Test
10072+
public void TestCloseToPowerOfTwo() {
10073+
for (int i = 31; i < 129; ++i) {
10074+
EInteger ei = EInteger.FromInt32(1).ShiftLeft(i);
10075+
{
10076+
AssertJSONDouble(
10077+
ei.toString(),
10078+
"double",
10079+
EFloat.FromEInteger(ei).ToDouble());
10080+
AssertJSONDouble(
10081+
ei.Add(1).toString(),
10082+
"double",
10083+
EFloat.FromEInteger(ei.Add(1)).ToDouble());
10084+
AssertJSONDouble(
10085+
ei.Subtract(2).toString(),
10086+
"double",
10087+
EFloat.FromEInteger(ei.Subtract(2)).ToDouble());
10088+
AssertJSONDouble(
10089+
ei.Add(2).toString(),
10090+
"double",
10091+
EFloat.FromEInteger(ei.Add(2)).ToDouble());
10092+
AssertJSONDouble(
10093+
ei.Subtract(2).toString(),
10094+
"double",
10095+
EFloat.FromEInteger(ei.Subtract(2)).ToDouble());
10096+
}
10097+
}
10098+
}
10099+
1007010100
@Test
1007110101
public void TestFromJsonStringFastCases() {
1007210102
JSONOptions op = new JSONOptions("numberconversion=double");
@@ -10077,8 +10107,6 @@ public void TestFromJsonStringFastCases() {
1007710107
Assert.assertEquals(
1007810108
JSONOptions.ConversionMode.IntOrFloat,
1007910109
op.getNumberConversion());
10080-
// System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
10081-
// sw.Start();
1008210110
String manyzeros = TestCommon.Repeat("0", 1000000);
1008310111
String manythrees = TestCommon.Repeat("3", 1000000);
1008410112
AssertJSONDouble(

0 commit comments

Comments
 (0)