Example #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());
 }
Example #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());
 }
Example #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());
 }
Example #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();
 }
Example #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());
 }
Example #6
0
 @Test(expected = SQLException.class)
 public void intTimeExceptionTest() throws SQLException {
   Member member = new Member(DynamicType.TIME, "name", new byte[4]);
   member.getInt();
 }
Example #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();
 }
Example #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());
 }