Package ns.foundation

Examples of ns.foundation.NSRange


    assertTrue(range.containsLocation(4));
    assertFalse(range.containsLocation(5));
  }

  public void testIntersectsRange() {
    NSRange range = new NSRange(2,3);
    NSRange otherRange = new NSRange(3, 3);
    assertTrue(range.intersectsRange(otherRange));
  }
View Full Code Here


    NSRange otherRange = new NSRange(3, 3);
    assertTrue(range.intersectsRange(otherRange));
  }

  public void testIsEmpty() {
    NSRange range = new NSRange(2,3);
    assertFalse(range.isEmpty());
   
    range = new NSRange(2, 0);
    assertTrue(range.isEmpty());
   
    try {
      range = new NSRange(0, -1);
      fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    }
  }
View Full Code Here

    } catch (IllegalArgumentException e) {
    }
  }

  public void testIsSubrangeOfRange() {
    NSRange range = new NSRange(2,3); //2,3,4
    NSRange otherRange = new NSRange(3, 2); //3,4
    assertTrue(otherRange.isSubrangeOfRange(range));
    assertFalse(range.isSubrangeOfRange(otherRange));
  }
View Full Code Here

    assertTrue(otherRange.isSubrangeOfRange(range));
    assertFalse(range.isSubrangeOfRange(otherRange));
  }

  public void testMaxRange() {
    NSRange range = new NSRange(2,3);
    assertEquals(5, range.maxRange());
   
    range = new NSRange(0, 0);
    assertEquals(0, range.maxRange());
  }
View Full Code Here

    range = new NSRange(0, 0);
    assertEquals(0, range.maxRange());
  }

  public void testRangeByIntersectingRange() {
    NSRange range = new NSRange(2,3); //2,3,4
    NSRange otherRange = new NSRange(3, 3); //3,4,5
    NSRange intersection = range.rangeByIntersectingRange(otherRange); //3,4
    assertEquals(new NSRange(3, 2), intersection);
  }
View Full Code Here

    NSRange intersection = range.rangeByIntersectingRange(otherRange); //3,4
    assertEquals(new NSRange(3, 2), intersection);
  }

  public void testRangeByUnioningRange() {
    NSRange range = new NSRange(2,3); //2,3,4
    NSRange otherRange = new NSRange(3, 3); //3,4,5
    NSRange union = range.rangeByUnioningRange(otherRange); //2,3,4,5
    assertEquals(new NSRange(2, 4), union);
  }
View Full Code Here

  public void testSubtractRangeNoIntersect() {
    NSMutableRange result1 = new NSMutableRange();
    NSMutableRange result2 = new NSMutableRange();
   
    // no intersection
    NSRange testRange = new NSRange(0, 2); // 0, 1
    NSRange subRange = new NSRange(2, 2)// 2, 3
    testRange.subtractRange(subRange, result1, result2);
    assertEquals(result1, new NSRange(0, 0));
    assertEquals(result2, new NSRange(0, 0));
  }
View Full Code Here

  public void testSubtractRangeTotalIntersect() {
    NSMutableRange result1 = new NSMutableRange();
    NSMutableRange result2 = new NSMutableRange();

    // total intersection
    NSRange testRange = new NSRange(1, 2); // 1, 2
    NSRange subRange = new NSRange(0, 4)// 0, 1, 2, 3, 4
    testRange.subtractRange(subRange, result1, result2);
    assertEquals(0, result1.length());
    assertEquals(0, result2.length());
  }
View Full Code Here

  public void testSubtractRangeStartIntersect() {
    NSMutableRange result1 = new NSMutableRange();
    NSMutableRange result2 = new NSMutableRange();

    // start intersection
    NSRange testRange = new NSRange(1, 2); // 1, 2
    NSRange subRange = new NSRange(0, 2);   // 0, 1
    testRange.subtractRange(subRange, result1, result2);
    assertEquals(new NSMutableRange(2, 1), result1);
    assertEquals(new NSMutableRange(0, 0), result2);
  }
View Full Code Here

  public void testSubtractRangeEndIntersect() {
    NSMutableRange result1 = new NSMutableRange();
    NSMutableRange result2 = new NSMutableRange();

    // end intersection
    NSRange testRange = new NSRange(1, 2); // 1, 2
    NSRange subRange = new NSRange(2,2);   // 2, 3
    testRange.subtractRange(subRange, result1, result2);
    assertEquals(new NSMutableRange(1, 1), result1);
    assertEquals(new NSMutableRange(0, 0), result2);
  }
View Full Code Here

TOP

Related Classes of ns.foundation.NSRange

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.