Skip to content

Commit

Permalink
edit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peteroupc committed Jul 16, 2020
1 parent 23bc244 commit 1acada5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
12 changes: 6 additions & 6 deletions CBORTest/CBORObjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7303,7 +7303,7 @@ public static void AssertJSONInteger(
}

[Test]
[Timeout(2000)]
[Timeout(10000)]
public void TestFromJsonStringLongSpecific1() {
JSONOptions jsonop = JSONOptions.Default;
string json = "{\"x\":-9.2574033594381E-7962\u002c\"1\":" +
Expand Down Expand Up @@ -7432,7 +7432,7 @@ public void TestFromJsonStringLongKindFull2() {
}

[Test]
[Timeout(2000)]
[Timeout(10000)]
public void TestFromJsonStringLongKindFullBad() {
Console.WriteLine("FullBad 1");
var jsonop = new JSONOptions("numberconversion=full");
Expand Down Expand Up @@ -7470,7 +7470,7 @@ public void TestFromJsonStringLongKindFullBad() {
}

[Test]
[Timeout(2000)]
[Timeout(10000)]
public void TestFromJsonStringLongKindsBad() {
JSONOptions jsonop;
string json = TestCommon.Repeat("7", 1000000) + "x";
Expand Down Expand Up @@ -7538,7 +7538,7 @@ public void TestFromJsonStringLongKindsBad() {
}

[Test]
[Timeout(2000)]
[Timeout(10000)]
public void TestFromJsonStringLongKindIntOrFloatFromDouble() {
var jsonop = new JSONOptions("numberconversion=intorfloatfromdouble");
string manysevens = TestCommon.Repeat("7", 1000000);
Expand All @@ -7557,7 +7557,7 @@ public void TestFromJsonStringLongKindIntOrFloatFromDouble() {
}

[Test]
[Timeout(2000)]
[Timeout(10000)]
public void TestFromJsonStringLongKindIntOrFloat() {
var jsonop = new JSONOptions("numberconversion=intorfloat");
string json = TestCommon.Repeat("7", 1000000);
Expand All @@ -7567,7 +7567,7 @@ public void TestFromJsonStringLongKindIntOrFloat() {
}

[Test]
[Timeout(2000)]
[Timeout(10000)]
public void TestFromJsonStringLongKindIntOrFloat2() {
var jsonop = new JSONOptions("numberconversion=intorfloat");
string json = "-" + TestCommon.Repeat("7", 1000000);
Expand Down
16 changes: 12 additions & 4 deletions CBORTest/CBORTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2725,6 +2725,12 @@ public void TestAsNumberAddSubtract() {
public static bool TestAsNumberMultiplyDivideOne(
CBORObject o1,
CBORObject o2) {
if (o1 == null) {
throw new ArgumentNullException(nameof(o1));
}
if (o2 == null) {
throw new ArgumentNullException(nameof(o2));
}
if (!o1.IsNumber || !o2.IsNumber) {
return false;
}
Expand Down Expand Up @@ -2761,7 +2767,9 @@ public static bool TestAsNumberMultiplyDivideOne(
"o1=" + TestCommon.ToByteArrayString(eb1) + "\n" +
"o2=" + TestCommon.ToByteArrayString(eb2) + "\n");
}
VerifyEqual(on2a, on2, o1, o2);
if (!on1.IsZero() && !on2.IsZero()) {
VerifyEqual(on2a, on2, o1, o2);
}
CBORNumber on1a = onSum.Divide(on2);
// NOTE: Ignore if divisor is zero
if (!on2.IsZero() && !on1a.IsFinite()) {
Expand All @@ -2773,7 +2781,7 @@ public static bool TestAsNumberMultiplyDivideOne(
"ecodeFromBytes(bytes1),\n" +
"CBORObject.DecodeFromBytes(bytes2));\n}\n");
}
if (!o1.IsZero() && !o2.IsZero()) {
if (!on1.IsZero() && !on2.IsZero()) {
VerifyEqual(on1a, on1, o1, o2);
}
return true;
Expand All @@ -2783,8 +2791,8 @@ public static bool TestAsNumberMultiplyDivideOne(
[Timeout(100000)]
public void TestAsNumberMultiplyDivide() {
var bo1 = new byte[] {
0x1b, 0x75, (byte)0xdd, (byte)0xb0, (byte)0xcc,
0x50, (byte)0x9b, (byte)0xd0, 0x2b,
0x1b, 0x75, (byte)0xdd, (byte)0xb0,
(byte)0xcc, 0x50, (byte)0x9b, (byte)0xd0, 0x2b,
};
var bo2 = new byte[] { (byte)0xc5, (byte)0x82, 0x23, 0x00 };
CBORObject cbor1 = CBORObject.DecodeFromBytes(bo1);
Expand Down
4 changes: 2 additions & 2 deletions CBORTest/RandomObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ public static EFloat CloseToPowerOfTwo(IRandomGenExtended rg) {
if (rg.GetInt32(10) == 0) {
pwr2 = pwr - (rg.GetInt32(100) < 80 ? IntInRange(rg, 51, 61) :
IntInRange(rg, 2, 300));
ef = (rg.GetInt32(2) == 0) ? (ef.Add(EFloat.Create(1, pwr2))) :
(ef.Subtract(EFloat.Create(1, pwr2)));
ef = (rg.GetInt32(2) == 0) ? ef.Add(EFloat.Create(1, pwr2)) :
ef.Subtract(EFloat.Create(1, pwr2));
}
return ef;
}
Expand Down

0 comments on commit 1acada5

Please sign in to comment.