01: package org.bouncycastle.asn1.test;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.util.test.SimpleTest;
05:
06: import java.math.BigInteger;
07:
08: public abstract class ASN1UnitTest extends SimpleTest {
09: protected void checkMandatoryField(String name,
10: ASN1Encodable expected, ASN1Encodable present) {
11: if (!expected.equals(present)) {
12: fail(name + " field doesn't match.");
13: }
14: }
15:
16: protected void checkMandatoryField(String name, String expected,
17: String present) {
18: if (!expected.equals(present)) {
19: fail(name + " field doesn't match.");
20: }
21: }
22:
23: protected void checkMandatoryField(String name, byte[] expected,
24: byte[] present) {
25: if (!areEqual(expected, present)) {
26: fail(name + " field doesn't match.");
27: }
28: }
29:
30: protected void checkMandatoryField(String name, int expected,
31: int present) {
32: if (expected != present) {
33: fail(name + " field doesn't match.");
34: }
35: }
36:
37: protected void checkOptionalField(String name,
38: ASN1Encodable expected, ASN1Encodable present) {
39: if (expected != null) {
40: if (!expected.equals(present)) {
41: fail(name + " field doesn't match.");
42: }
43: } else if (present != null) {
44: fail(name + " field found when none expected.");
45: }
46: }
47:
48: protected void checkOptionalField(String name, String expected,
49: String present) {
50: if (expected != null) {
51: if (!expected.equals(present)) {
52: fail(name + " field doesn't match.");
53: }
54: } else if (present != null) {
55: fail(name + " field found when none expected.");
56: }
57: }
58:
59: protected void checkOptionalField(String name, BigInteger expected,
60: BigInteger present) {
61: if (expected != null) {
62: if (!expected.equals(present)) {
63: fail(name + " field doesn't match.");
64: }
65: } else if (present != null) {
66: fail(name + " field found when none expected.");
67: }
68: }
69:
70: }
|