Skip to content

Commit 9dcea08

Browse files
committed
add timeouts to test cases
1 parent 3877574 commit 9dcea08

11 files changed

+356
-0
lines changed

CBORTest/BEncodingTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static void DoTestString(string value) {
4545
}
4646

4747
[Test]
48+
[Timeout(30000)]
4849
public void TestLong() {
4950
DoTestLong(0);
5051
DoTestLong(-1);
@@ -55,6 +56,7 @@ public void TestLong() {
5556
}
5657

5758
[Test]
59+
[Timeout(30000)]
5860
public void TestList() {
5961
var beo = CBORObject.NewArray();
6062
_ = beo.Add(ToObjectTest.TestToFromObjectRoundTrip(1));
@@ -96,6 +98,7 @@ public void TestList() {
9698
}
9799

98100
[Test]
101+
[Timeout(30000)]
99102
public void TestDictionary() {
100103
var beo = CBORObject.NewMap();
101104
beo["zero"] = ToObjectTest.TestToFromObjectRoundTrip(1);
@@ -137,6 +140,7 @@ public void TestDictionary() {
137140
}
138141

139142
[Test]
143+
[Timeout(30000)]
140144
public void TestString() {
141145
DoTestString(String.Empty);
142146
DoTestString(" ");

CBORTest/CBORDataUtilitiesTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ private static void AssertNegative(CBORObject obj) {
1212
}
1313

1414
[Test]
15+
[Timeout(30000)]
1516
public void TestPreserveNegativeZero() {
1617
CBORObject cbor;
1718
var pnz = new
@@ -82,6 +83,7 @@ public void TestPreserveNegativeZero() {
8283

8384
// testing obsolete method
8485
[Test]
86+
[Timeout(30000)]
8587
public void TestParseJSONNumberSubstring() {
8688
string tstr =
8789

@@ -99,6 +101,7 @@ public void TestParseJSONNumberSubstring() {
99101
}
100102

101103
[Test]
104+
[Timeout(30000)]
102105
public void TestParseJSONNumberNegativeZero() {
103106
var strings = new string[] {
104107
"-0", "0", "-0E+0", "0", "-0E-0", "0", "-0E-1", "0.0",
@@ -151,6 +154,7 @@ public void TestParseJSONNumberNegativeZero() {
151154
};
152155

153156
[Test]
157+
[Timeout(30000)]
154158
public void TestParseJSONNumber() {
155159
foreach (string str in BadJsonNumbers) {
156160
if (CBORDataUtilities.ParseJSONNumber(str) != null) {

CBORTest/CBORExceptionTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Test {
66
[TestFixture]
77
public class CBORExceptionTest {
88
[Test]
9+
[Timeout(30000)]
910
public void TestConstructor() {
1011
try {
1112
throw new CBORException("Test exception");

CBORTest/CBORExtraTest.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private static decimal RandomDecimal(RandomGenerator rand, int exponent) {
4242
}
4343

4444
[Test]
45+
[Timeout(30000)]
4546
public void TestCBORObjectDecimal() {
4647
var rand = new RandomGenerator();
4748
for (int i = 0; i <= 28; ++i) {
@@ -142,6 +143,7 @@ public void TestCBORObjectDecimal() {
142143
}
143144

144145
[Test]
146+
[Timeout(30000)]
145147
public void TestSByte() {
146148
for (int i = sbyte.MinValue; i <= sbyte.MaxValue; ++i) {
147149
CBORTestCommon.AssertJSONSer(
@@ -363,6 +365,7 @@ public System.Collections.Generic.IEnumerator<byte>
363365
}
364366

365367
[Test]
368+
[Timeout(30000)]
366369
public void TestCustomFlagsEnum() {
367370
var cbor = CBORObject.FromObject(CustomBits.A | CustomBits.B);
368371
Assert.AreEqual(CBORObject.FromInt32(3), cbor);
@@ -375,6 +378,7 @@ public void TestCustomFlagsEnum() {
375378
}
376379

377380
[Test]
381+
[Timeout(30000)]
378382
public void TestCustomCollection() {
379383
var clist = new CustomCollection
380384
{
@@ -442,6 +446,7 @@ private enum AULong : ulong
442446
}
443447

444448
[Test]
449+
[Timeout(30000)]
445450
public void TestCPOD2() {
446451
var m = new CPOD2
447452
{
@@ -575,6 +580,7 @@ from x in arrao
575580
}
576581

577582
[Test]
583+
[Timeout(30000)]
578584
public void TestArbitraryTypes() {
579585
var obj = CBORObject.FromObject(new
580586
{
@@ -661,6 +667,7 @@ from i in RangeExclusive(0, 10)
661667

662668
#if !NET20 && !NET40
663669
[Test]
670+
[Timeout(30000)]
664671
public void TestReadOnlyCollection() {
665672
IReadOnlyCollection<int> roc = new ReadOnlyCollection<int>(new int[] {
666673
0, 1, 99, 2, 3, 99,
@@ -746,6 +753,7 @@ public void TestReadOnlyCollection() {
746753
}
747754

748755
[Test]
756+
[Timeout(30000)]
749757
public void TestReadOnlyDictionary() {
750758
var dict = new Dictionary<string, int>
751759
{
@@ -794,6 +802,7 @@ public void TestReadOnlyDictionary() {
794802
#endif
795803

796804
[Test]
805+
[Timeout(30000)]
797806
public void TestMultidimArray() {
798807
int[,] arr = { { 0, 1, 99 }, { 2, 3, 299 } };
799808
var cbor = CBORObject.FromObject(arr);
@@ -826,6 +835,7 @@ public void TestMultidimArray() {
826835
}
827836

828837
[Test]
838+
[Timeout(30000)]
829839
public void TestFloatCloseToEdge() {
830840
try {
831841
_ = ToObjectTest.TestToFromObjectRoundTrip(
@@ -6406,6 +6416,7 @@ public void TestFloatCloseToEdge() {
64066416
}
64076417

64086418
[Test]
6419+
[Timeout(30000)]
64096420
public void TestULong() {
64106421
ulong[] ranges = {
64116422
0, 65539, 0xfffff000UL, 0x100000400UL,
@@ -6464,6 +6475,7 @@ private static short DivideUnsigned(int x, short y) {
64646475
}
64656476

64666477
[Test]
6478+
[Timeout(30000)]
64676479
public void TestOther() {
64686480
int[,,] arr3 = new int[2, 3, 2];
64696481
var cbor = CBORObject.FromObject(arr3);
@@ -6476,6 +6488,7 @@ public void TestOther() {
64766488
}
64776489

64786490
[Test]
6491+
[Timeout(30000)]
64796492
public void TestDivideUnsigned() {
64806493
var fr = new RandomGenerator();
64816494
unchecked {
@@ -6498,6 +6511,7 @@ public void TestDivideUnsigned() {
64986511
}
64996512

65006513
[Test]
6514+
[Timeout(30000)]
65016515
public void TestUInt() {
65026516
uint[] ranges = {
65036517
0, 65539,
@@ -6518,6 +6532,7 @@ public void TestUInt() {
65186532
}
65196533

65206534
[Test]
6535+
[Timeout(30000)]
65216536
public void TestDecimal() {
65226537
CBORObject cbor = ToObjectTest.TestToFromObjectRoundTrip(
65236538
decimal.MinValue);
@@ -6545,6 +6560,7 @@ public void TestDecimal() {
65456560
}
65466561

65476562
[Test]
6563+
[Timeout(30000)]
65486564
public void TestUShort() {
65496565
for (int i = ushort.MinValue; i <= ushort.MaxValue; ++i) {
65506566
CBORTestCommon.AssertJSONSer(
@@ -6563,13 +6579,15 @@ public ExoticStruct(int pv) {
65636579
}
65646580

65656581
[Test]
6582+
[Timeout(30000)]
65666583
public void TestToObjectNull() {
65676584
CBORObject cbor = CBORObject.Null;
65686585
Assert.AreEqual(null, (string)cbor.ToObject(typeof(string)));
65696586
Assert.AreEqual(null, cbor.ToObject<string>());
65706587
}
65716588

65726589
[Test]
6590+
[Timeout(30000)]
65736591
public void TestNullable() {
65746592
int? nvalue = 1;
65756593
var cbor = CBORObject.FromObject((object)nvalue);
@@ -6596,6 +6614,7 @@ public void TestNullable() {
65966614
}
65976615

65986616
[Test]
6617+
[Timeout(30000)]
65996618
public void TestDoubleToOther() {
66006619
CBORObject dbl1 =
66016620
ToObjectTest.TestToFromObjectRoundTrip((double)Int32.MinValue);

0 commit comments

Comments
 (0)