Package java.text

Examples of java.text.Bidi


            assertEquals(expectedRuns[i][0], bi.getRunStart(i));
            assertEquals(expectedRuns[i][1], bi.getRunLimit(i));
        }
    }
       public void testGetRunLimit() {
         bd = new Bidi("text", Bidi.DIRECTION_LEFT_TO_RIGHT);
         try {
             assertTrue(4 == bd.getRunLimit(-1));
         } catch (Exception e) {
                       fail("Unexpected exception: " + e);
         }
View Full Code Here


                       fail("Unexpected exception: " + e);
         }
       }
       public void testBidiConstructor_Iterator() {
               AttributedString paragraph = new AttributedString("text");
         bd = new Bidi(paragraph.getIterator());
         try {
             assertTrue(4 == bd.getRunLimit(1));
         } catch (Exception e) {
                       fail("Unexpected exception: " + e);
         }
View Full Code Here

    }
  }

  public void testNullPointerConstructor() {
    try {
      bd = new Bidi(null, Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi(null, 0, new byte[] { 0 }, 0, 0,
          Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
            bd = new Bidi(null);
            fail("should throw IAE");
        } catch (IllegalArgumentException e) {
        }

    bd = new Bidi("a".toCharArray(), 0, null, 0, 1,
        Bidi.DIRECTION_RIGHT_TO_LEFT);
  }
View Full Code Here

        Bidi.DIRECTION_RIGHT_TO_LEFT);
  }

  public void testBadLength() {
    try {
      bd = new Bidi("1".toCharArray(), 0, new byte[] { 0 }, 0, 20,
          Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi("1234567".toCharArray(), 0, new byte[] { 0 }, 0, 4,
          Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi("1234567".toCharArray(), 4, new byte[] { 0, 1, 2, 3,
          4 }, 0, 5, Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi("1234567".toCharArray(), 0, new byte[] { 0, 1, 2, 3,
          4 }, 4, 5, Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

        //regression for HARMONY-1031
    try {
      bd = new Bidi(new char[] { 't','t','t'}, -1, new byte[] { 2, 2 }, 1, 1, 1);
      fail("should be IAE");         
    } catch (IllegalArgumentException e) {
      // expected
    }
   
    try {
      bd = new Bidi(new char[] { 't','t','t'}, 1, new byte[] { 2, 2 }, -1, 1, 1);
      fail("should be IAE");         
    } catch (IllegalArgumentException e) {
      // expected
    }
   
    try {
      bd = new Bidi(new char[] { 't','t','t'}, 1, new byte[] { 2, 2 }, 1, -1, 1);
      fail("should be IAE");         
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi(new char[] {}, 5, new byte[] { 2, 2, 2, 2, 2, 2 }, 8, Integer.MAX_VALUE, 5);
      fail("should be IAE");         
    } catch (IllegalArgumentException e) {
      // expected
    }

        try {
            bd = new Bidi(null, 5, null, 8, Integer.MAX_VALUE, 5);
            fail("should be IAE");                 
        } catch (IllegalArgumentException e) {
            // expected
        }
       
    bd = new Bidi(new char[] {'o'}, 0, new byte[] { 2, 2}, 2, 0, 2 );
  }
View Full Code Here

       
    bd = new Bidi(new char[] {'o'}, 0, new byte[] { 2, 2}, 2, 0, 2 );
  }

  public void testEmptyParagraph() {
    bd = new Bidi("", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 0, 0 } }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 0, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());

    bd = new Bidi("", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 0, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("", Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
View Full Code Here

    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());
  }

  public void testSpaceParagraph() {
    bd = new Bidi(" ", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(" ", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());

    bd = new Bidi(" ", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(" ", Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
View Full Code Here

    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());
  }

  public void testSimpleParagraph() {
    bd = new Bidi("t", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("t", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("t", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
View Full Code Here

    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());
  }

  public void testBadFlags() {
    bd = new Bidi("", 173);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
View Full Code Here

    assertFalse(bd.isRightToLeft());
  }

  public void testBadEmbeddings() {
    try {
      bd = new Bidi("".toCharArray(), 0, new byte[] {}, 0, 1,
          Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }
View Full Code Here

      // expected
    }
  }

  public void testOverrideEmbeddings() {
    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -7,
        (byte) -2, (byte) -3 }, 0, 3,
        Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(7, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 7 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
        (byte) -2, (byte) -3 }, 0, 3,
        Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
        (byte) -2, (byte) -3 }, 0, 3, Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
        (byte) -2, (byte) -3 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
View Full Code Here

TOP

Related Classes of java.text.Bidi

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.