public void TestFromObjectAndTag()
{
EInteger bigvalue = EInteger.FromString("99999999999999999999999999999");
try {
CBORObject.FromObjectAndTag(2, bigvalue);
Assert.Fail("Should have failed");
} catch (ArgumentException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
try {
CBORObject.FromObjectAndTag(2, -1);
Assert.Fail("Should have failed");
} catch (ArgumentException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
try {
CBORObject.FromObjectAndTag(CBORObject.Null, -1);
Assert.Fail("Should have failed");
} catch (ArgumentException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
try {
CBORObject.FromObjectAndTag(CBORObject.Null, 999999);
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
EInteger eintNull = null;
try {
CBORObject.FromObjectAndTag(2, eintNull);
Assert.Fail("Should have failed");
} catch (ArgumentNullException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
try {
CBORObject.FromObjectAndTag(2, EInteger.FromString("-1"));
Assert.Fail("Should have failed");
} catch (ArgumentException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
}