public void TestSingleElement() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(99); string expecting = "99"; Assert.AreEqual(s.ToString(), expecting); }
public void TestSubtractOfCompletelyContainedRange() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(10, 20); IntervalSet s2 = IntervalSet.Of(12, 15); string expecting = "{10..11, 16..20}"; string result = (s.Subtract(s2)).ToString(); assertEquals(result, expecting); }
public void TestRangeAndIsolatedElement() /*throws Exception*/ { IntervalSet s = IntervalSet.Of('a', 'z'); IntervalSet s2 = IntervalSet.Of('d'); string expecting = "100"; string result = (s.And(s2)).ToString(); Assert.AreEqual(result, expecting); }
public void TestEmptyIntersection() /*throws Exception*/ { IntervalSet s = IntervalSet.Of('a', 'z'); IntervalSet s2 = IntervalSet.Of('0', '9'); string expecting = "{}"; string result = (s.And(s2)).ToString(); assertEquals(result, expecting); }
public void TestNotEqualSet() /*throws Exception*/ { IntervalSet vocabulary = IntervalSet.Of(1, 1000); IntervalSet s = IntervalSet.Of(1, 1000); string expecting = "{}"; string result = (s.Complement(vocabulary)).ToString(); assertEquals(result, expecting); }
public void TestSimpleAnd() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(10, 20); IntervalSet s2 = IntervalSet.Of(13, 15); string expecting = "13..15"; string result = (s.And(s2)).ToString(); Assert.AreEqual(result, expecting); }
private void HandleSetElementCharRange(IIntSet elements, GrammarAST c1, GrammarAST c2) { if (grammar.type == GrammarType.Lexer) { int a = Grammar.GetCharValueFromGrammarCharLiteral(c1.Text); int b = Grammar.GetCharValueFromGrammarCharLiteral(c2.Text); elements.AddAll(IntervalSet.Of(a, b)); } }
public void TestComplement2() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(100, 101); Interval s2 = Interval.FromBounds(100, 102); string expecting = "102"; string result = (s.Complement(s2)).ToString(); Assert.AreEqual(result, expecting); }
public void TestNotSetEdgeElement() /*throws Exception*/ { IntervalSet vocabulary = IntervalSet.Of(1, 2); IntervalSet s = IntervalSet.Of(1); string expecting = "2"; string result = (s.Complement(vocabulary)).ToString(); Assert.AreEqual(result, expecting); }
public void TestEmptyIntersectionSingleElements() /*throws Exception*/ { IntervalSet s = IntervalSet.Of('a'); IntervalSet s2 = IntervalSet.Of('d'); string expecting = "{}"; string result = (s.And(s2)).ToString(); Assert.AreEqual(result, expecting); }
public void TestSubtractOfCompletelyCoveredRange() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(10, 20); IntervalSet s2 = IntervalSet.Of(1, 25); string expecting = "{}"; string result = (s.Subtract(s2)).ToString(); Assert.AreEqual(result, expecting); }
public void TestComplement3() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(1, 96); s.Add(99, Label.MAX_CHAR_VALUE); string expecting = "97..98"; string result = (s.Complement(1, Label.MAX_CHAR_VALUE)).ToString(); Assert.AreEqual(result, expecting); }
public void TestMergeWithDoubleOverlap() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(1, 10); s.Add(20, 30); s.Add(5, 25); // overlaps two! string expecting = "1..30"; string result = s.ToString(); Assert.AreEqual(result, expecting); }
public void TestComplement() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(100, 100); s.Add(101, 101); IntervalSet s2 = IntervalSet.Of(100, 102); string expecting = "102"; string result = (s.Complement(s2)).ToString(); assertEquals(result, expecting); }
public void TestNotSingleElement() /*throws Exception*/ { IntervalSet vocabulary = IntervalSet.Of(1, 1000); vocabulary.Add(2000, 3000); IntervalSet s = IntervalSet.Of(50, 50); string expecting = "{1..49, 51..1000, 2000..3000}"; string result = (s.Complement(vocabulary)).ToString(); Assert.AreEqual(result, expecting); }
public void TestSingleElementMinusDisjointSet() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(15, 15); IntervalSet s2 = IntervalSet.Of(1, 5); s2.Add(10, 20); string expecting = "{}"; // 15 - {1..5, 10..20} = {} string result = s.Subtract(s2).ToString(); Assert.AreEqual(result, expecting); }
public void TestSize() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(20, 30); s.Add(50, 55); s.Add(5, 19); string expecting = "32"; string result = s.Count.ToString(); Assert.AreEqual(result, expecting); }
public void TestMergeOfRangesAndSingleValuesReverse() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(43, 65534); s.Add(42); s.Add(0, 41); string expecting = "0..65534"; string result = s.ToString(); Assert.AreEqual(result, expecting); }
public void TestMergeOfRangesAndSingleValues() /*throws Exception*/ { // {0..41, 42, 43..65534} IntervalSet s = IntervalSet.Of(0, 41); s.Add(42); s.Add(43, 65534); string expecting = "0..65534"; string result = s.ToString(); assertEquals(result, expecting); }
public virtual StateCluster BuildRange(int a, int b) { NFAState left = NewState(); NFAState right = NewState(); Label label = new Label(IntervalSet.Of(a, b)); Transition e = new Transition(label, right); left.AddTransition(e); StateCluster g = new StateCluster(left, right); return(g); }
public void TestNotSet() /*throws Exception*/ { IntervalSet vocabulary = IntervalSet.Of(1, 1000); IntervalSet s = IntervalSet.Of(50, 60); s.Add(5); s.Add(250, 300); string expecting = "{1..4, 6..49, 61..249, 301..1000}"; string result = (s.Complement(vocabulary)).ToString(); Assert.AreEqual(result, expecting); }
public void TestIntersectionWithTwoContainedElementsReversed() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(10, 20); IntervalSet s2 = IntervalSet.Of(2, 2); s2.Add(15); s2.Add(18); string expecting = "{15, 18}"; string result = (s2.And(s)).ToString(); Assert.AreEqual(result, expecting); }
public void TestSubtractOfWackyRange() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(0, 113); s.Add(115, 200); IntervalSet s2 = IntervalSet.Of(0, 115); s2.Add(117, 200); string expecting = "116"; string result = (s.Subtract(s2)).ToString(); Assert.AreEqual(result, expecting); }
public void TestMembership() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(15, 15); s.Add(50, 60); Assert.IsTrue(!s.Contains(0)); Assert.IsTrue(!s.Contains(20)); Assert.IsTrue(!s.Contains(100)); Assert.IsTrue(s.Contains(15)); Assert.IsTrue(s.Contains(55)); Assert.IsTrue(s.Contains(50)); Assert.IsTrue(s.Contains(60)); }
public void TestNotRIntersectionNotT() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(0, 's'); s.Add('u', 200); IntervalSet s2 = IntervalSet.Of(0, 'q'); s2.Add('s', 200); string expecting = "{0..113, 115, 117..200}"; string result = (s.And(s2)).ToString(); Assert.AreEqual(result, expecting); }
public void TestToList() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(20, 25); s.Add(50, 55); s.Add(5, 5); string expecting = "[5, 20, 21, 22, 23, 24, 25, 50, 51, 52, 53, 54, 55]"; IList foo = new List <object>(); //String result = String.valueOf( s.toList() ); string result = "[" + string.Join(", ", s.ToArray().Select(i => i.ToString()).ToArray()) + "]"; Assert.AreEqual(result, expecting); }
public void TestMergeWhereAdditionMergesTwoExistingIntervals() /*throws Exception*/ { // 42, 10, {0..9, 11..41, 43..65534} IntervalSet s = IntervalSet.Of(42); s.Add(10); s.Add(0, 9); s.Add(43, 65534); s.Add(11, 41); string expecting = "0..65534"; string result = s.ToString(); Assert.AreEqual(result, expecting); }
public void TestSimpleEquals() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(10, 20); IntervalSet s2 = IntervalSet.Of(10, 20); Boolean expecting = true; Boolean result = s.Equals(s2); Assert.AreEqual(result, expecting); IntervalSet s3 = IntervalSet.Of(15, 55); expecting = false; result = s.Equals(s3); Assert.AreEqual(result, expecting); }
public void TestSubtractOfOverlappingRangeFromLeft() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(10, 20); IntervalSet s2 = IntervalSet.Of(5, 11); string expecting = "12..20"; string result = (s.Subtract(s2)).ToString(); Assert.AreEqual(result, expecting); IntervalSet s3 = IntervalSet.Of(5, 10); expecting = "11..20"; result = (s.Subtract(s3)).ToString(); Assert.AreEqual(result, expecting); }
public void TestSubtractOfOverlappingRangeFromRight() /*throws Exception*/ { IntervalSet s = IntervalSet.Of(10, 20); IntervalSet s2 = IntervalSet.Of(15, 25); string expecting = "10..14"; string result = (s.Subtract(s2)).ToString(); Assert.AreEqual(result, expecting); IntervalSet s3 = IntervalSet.Of(20, 25); expecting = "10..19"; result = (s.Subtract(s3)).ToString(); Assert.AreEqual(result, expecting); }