Package thrift.test

Examples of thrift.test.ComparableUnion


    // should not throw an exception
    union.toString();
  }

  public void testCompareTo() throws Exception {
    ComparableUnion cu = ComparableUnion.string_field("a");
    ComparableUnion cu2 = ComparableUnion.string_field("b");

    assertTrue(cu.compareTo(cu) == 0);
    assertTrue(cu2.compareTo(cu2) == 0);

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);

    cu2 = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{2}));

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);

    cu = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{1}));

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);
   
    TestUnion union1 = new TestUnion(TestUnion._Fields.STRUCT_LIST, new ArrayList<RandomStuff>());
    TestUnion union2 = new TestUnion(TestUnion._Fields.STRUCT_LIST, new ArrayList<RandomStuff>());
    assertTrue(union1.compareTo(union2) == 0);
View Full Code Here


  }

  public void testDeepCopy() throws Exception {
    byte[] bytes = {1, 2, 3};
    ByteBuffer value = ByteBuffer.wrap(bytes);
    ComparableUnion cu = ComparableUnion.binary_field(value);
    ComparableUnion copy = cu.deepCopy();
    assertEquals(cu, copy);
    assertNotSame(cu.bufferForBinary_field().array(), copy.bufferForBinary_field().array());
  }
View Full Code Here

  }
 
  public void testToString() throws Exception {
    byte[] bytes = {1, 2, 3};
    ByteBuffer value = ByteBuffer.wrap(bytes);
    ComparableUnion cu = ComparableUnion.binary_field(value);
    String expectedString = "<ComparableUnion binary_field:01 02 03>";
    assertEquals(expectedString, cu.toString());
  }
View Full Code Here

    // should not throw an exception
    union.toString();
  }

  public void testCompareTo() throws Exception {
    ComparableUnion cu = ComparableUnion.string_field("a");
    ComparableUnion cu2 = ComparableUnion.string_field("b");

    assertTrue(cu.compareTo(cu) == 0);
    assertTrue(cu2.compareTo(cu2) == 0);

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);

    cu2 = ComparableUnion.binary_field(new byte[]{2});

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);

    cu = ComparableUnion.binary_field(new byte[]{1});

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);
  }
View Full Code Here

    // should not throw an exception
    union.toString();
  }

  public void testCompareTo() throws Exception {
    ComparableUnion cu = ComparableUnion.string_field("a");
    ComparableUnion cu2 = ComparableUnion.string_field("b");

    assertTrue(cu.compareTo(cu) == 0);
    assertTrue(cu2.compareTo(cu2) == 0);

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);

    cu2 = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{2}));

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);

    cu = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{1}));

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);
   
    TestUnion union1 = new TestUnion(TestUnion._Fields.STRUCT_LIST, new ArrayList<RandomStuff>());
    TestUnion union2 = new TestUnion(TestUnion._Fields.STRUCT_LIST, new ArrayList<RandomStuff>());
    assertTrue(union1.compareTo(union2) == 0);
View Full Code Here

  }

  public void testDeepCopy() throws Exception {
    byte[] bytes = {1, 2, 3};
    ByteBuffer value = ByteBuffer.wrap(bytes);
    ComparableUnion cu = ComparableUnion.binary_field(value);
    ComparableUnion copy = cu.deepCopy();
    assertEquals(cu, copy);
    assertNotSame(cu.bufferForBinary_field().array(), copy.bufferForBinary_field().array());
  }
View Full Code Here

  }
 
  public void testToString() throws Exception {
    byte[] bytes = {1, 2, 3};
    ByteBuffer value = ByteBuffer.wrap(bytes);
    ComparableUnion cu = ComparableUnion.binary_field(value);
    String expectedString = "<ComparableUnion binary_field:01 02 03>";
    assertEquals(expectedString, cu.toString());
  }
View Full Code Here

    swau.write(proto);
    new Empty().read(proto);
  }
 
  public static void testCompareTo() throws Exception {
    ComparableUnion cu = ComparableUnion.string_field("a");
    ComparableUnion cu2 = ComparableUnion.string_field("b");

    if (cu.compareTo(cu2) != -1) {
      throw new RuntimeException("a was supposed to be < b, but was " + cu.compareTo(cu2));
    }

    if (cu2.compareTo(cu) != 1) {
      throw new RuntimeException("b was supposed to be > a, but was " + cu2.compareTo(cu));
    }

    cu2 = ComparableUnion.binary_field(new byte[]{2});

    if (cu.compareTo(cu2) != -1) {
      throw new RuntimeException("a was supposed to be < b, but was " + cu.compareTo(cu2));
    }

    if (cu2.compareTo(cu) != 1) {
      throw new RuntimeException("b was supposed to be > a, but was " + cu2.compareTo(cu));
    }

    cu = ComparableUnion.binary_field(new byte[]{1});

    if (cu.compareTo(cu2) != -1) {
      throw new RuntimeException("a was supposed to be < b, but was " + cu.compareTo(cu2));
    }

    if (cu2.compareTo(cu) != 1) {
      throw new RuntimeException("b was supposed to be > a, but was " + cu2.compareTo(cu));
    }
  }
View Full Code Here

    // should not throw an exception
    union.toString();
  }

  public void testCompareTo() throws Exception {
    ComparableUnion cu = ComparableUnion.string_field("a");
    ComparableUnion cu2 = ComparableUnion.string_field("b");

    assertTrue(cu.compareTo(cu) == 0);
    assertTrue(cu2.compareTo(cu2) == 0);

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);

    cu2 = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{2}));

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);

    cu = ComparableUnion.binary_field(ByteBuffer.wrap(new byte[]{1}));

    assertTrue(cu.compareTo(cu2) < 0);
    assertTrue(cu2.compareTo(cu) > 0);
   
    TestUnion union1 = new TestUnion(TestUnion._Fields.STRUCT_LIST, new ArrayList<RandomStuff>());
    TestUnion union2 = new TestUnion(TestUnion._Fields.STRUCT_LIST, new ArrayList<RandomStuff>());
    assertTrue(union1.compareTo(union2) == 0);
View Full Code Here

  }

  public void testDeepCopy() throws Exception {
    byte[] bytes = {1, 2, 3};
    ByteBuffer value = ByteBuffer.wrap(bytes);
    ComparableUnion cu = ComparableUnion.binary_field(value);
    ComparableUnion copy = cu.deepCopy();
    assertEquals(cu, copy);
    assertNotSame(cu.bufferForBinary_field().array(), copy.bufferForBinary_field().array());
  }
View Full Code Here

TOP

Related Classes of thrift.test.ComparableUnion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.