| | |
| | | @Test(dataProvider = "intValues") |
| | | public void testIntValue(int i) |
| | | { |
| | | assertEquals(i, new ASN1Integer(i).intValue()); |
| | | assertEquals(new ASN1Integer(i).intValue(), i); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | ASN1Integer integerElement = new ASN1Integer(0); |
| | | integerElement.setValue(i); |
| | | assertEquals(i, integerElement.intValue()); |
| | | assertEquals(integerElement.intValue(), i); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | integerElement.setValue(encoding); |
| | | assertEquals(i, integerElement.intValue()); |
| | | assertEquals(integerElement.intValue(), i); |
| | | } |
| | | |
| | | |
| | |
| | | // First, make sure that we can decode an integer element as an integer. |
| | | ASN1Element e = new ASN1Integer(i); |
| | | ASN1Integer integerElement = ASN1Integer.decodeAsInteger(e); |
| | | assertEquals(i, integerElement.intValue()); |
| | | assertEquals(integerElement.intValue(), i); |
| | | |
| | | e = new ASN1Integer((byte) 0x50, i); |
| | | integerElement = ASN1Integer.decodeAsInteger(e); |
| | | assertEquals(i, integerElement.intValue()); |
| | | assertEquals(integerElement.intValue(), i); |
| | | |
| | | |
| | | // Next, make sure that we can decode a generic element as an integer. |
| | |
| | | |
| | | e = new ASN1Element(ASN1Constants.UNIVERSAL_INTEGER_TYPE, encoding); |
| | | integerElement = ASN1Integer.decodeAsInteger(e); |
| | | assertEquals(i, integerElement.intValue()); |
| | | assertEquals(integerElement.intValue(), i); |
| | | |
| | | e = new ASN1Element((byte) 0x50, encoding); |
| | | integerElement = ASN1Integer.decodeAsInteger(e); |
| | | assertEquals(i, integerElement.intValue()); |
| | | assertEquals(integerElement.intValue(), i); |
| | | } |
| | | |
| | | |
| | |
| | | System.arraycopy(encoding, 0, encodedElement, 2, encoding.length); |
| | | |
| | | ASN1Integer integerElement = ASN1Integer.decodeAsInteger(encodedElement); |
| | | assertEquals(i, integerElement.intValue()); |
| | | assertEquals(integerElement.intValue(), i); |
| | | } |
| | | |
| | | |
| | |
| | | System.arraycopy(encoding, 0, encodedElement, 3, encoding.length); |
| | | |
| | | ASN1Integer integerElement = ASN1Integer.decodeAsInteger(encodedElement); |
| | | assertEquals(i, integerElement.intValue()); |
| | | assertEquals(integerElement.intValue(), i); |
| | | } |
| | | |
| | | |