Beispiel #1
0
 @Test
 public void intOneByteArrayTest() throws SQLException {
   byte[] oneByteValue = new byte[1];
   oneByteValue[0] = 0x01;
   Member member = new Member(DynamicType.INT, "name", oneByteValue);
   Assert.assertEquals(1, member.getInt());
 }
Beispiel #2
0
 @Test
 public void intUnsignedFourByteArrayTest() throws SQLException {
   byte[] oneByteValue = new byte[4];
   oneByteValue[0] = (byte) 0x00;
   oneByteValue[1] = (byte) 0x00;
   oneByteValue[2] = (byte) 0x00;
   oneByteValue[3] = (byte) 0x80;
   Member member = new Member(DynamicType.UINT, "name", oneByteValue);
   Assert.assertEquals(Integer.MAX_VALUE + 1L, member.getUInt());
 }
Beispiel #3
0
 @Test
 public void intFourByteArrayNegativeTest() throws SQLException {
   byte[] oneByteValue = new byte[4];
   oneByteValue[0] = (byte) 0x00;
   oneByteValue[1] = (byte) 0x00;
   oneByteValue[2] = (byte) 0x00;
   oneByteValue[3] = (byte) 0x80;
   Member member = new Member(DynamicType.INT, "name", oneByteValue);
   Assert.assertEquals(Integer.MIN_VALUE, member.getInt());
 }
Beispiel #4
0
 @Test(expected = SQLException.class)
 public void intFromLongNotValidTest() throws SQLException {
   byte[] oneByteValue = new byte[8];
   oneByteValue[0] = 0x00;
   oneByteValue[1] = 0x00;
   oneByteValue[2] = 0x00;
   oneByteValue[3] = 0x00;
   oneByteValue[4] = 0x00;
   oneByteValue[5] = 0x00;
   oneByteValue[6] = 0x00;
   oneByteValue[7] = 0x01;
   Member member = new Member(DynamicType.DOUBLE, "name", oneByteValue);
   member.getInt();
 }
Beispiel #5
0
 @Test
 public void intFromLongValidTest() throws SQLException {
   byte[] oneByteValue = new byte[8];
   oneByteValue[0] = 0x00;
   oneByteValue[1] = 0x00;
   oneByteValue[2] = 0x00;
   oneByteValue[3] = 0x01;
   oneByteValue[4] = 0x00;
   oneByteValue[5] = 0x00;
   oneByteValue[6] = 0x00;
   oneByteValue[7] = 0x00;
   Member member = new Member(DynamicType.DOUBLE, "name", oneByteValue);
   Assert.assertEquals(16777216, member.getInt());
 }
Beispiel #6
0
 @Test(expected = SQLException.class)
 public void intTimeExceptionTest() throws SQLException {
   Member member = new Member(DynamicType.TIME, "name", new byte[4]);
   member.getInt();
 }
Beispiel #7
0
 @Test(expected = SQLException.class)
 public void intStringMoreThanIntArrayTest() throws SQLException {
   byte[] oneByteValue = "167772168999999".getBytes();
   Member member = new Member(DynamicType.STRING, "name", oneByteValue);
   member.getInt();
 }
Beispiel #8
0
 @Test
 public void intStringTest() throws SQLException {
   byte[] oneByteValue = "16777216".getBytes();
   Member member = new Member(DynamicType.STRING, "name", oneByteValue);
   Assert.assertEquals(16777216, member.getInt());
 }