public void AddEdge03() { AdjacencyGraph adjacencyGraph; VertexAndEdgeProvider s0 = new VertexAndEdgeProvider(); adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, true, 0); ((GenericMutableGraphTestNEW)this).AddEdge(adjacencyGraph); PexAssert.IsNotNull((object)adjacencyGraph); PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected); PexAssert.IsNotNull(adjacencyGraph.Provider); PexAssert.IsNotNull(adjacencyGraph.Edges); }
public void RemoveSettings() { storage.SaveSetting("X", 5); storage.SaveSetting("NAME", "Charlie"); storage.RemoveSetting("X"); PexAssert.IsNull(storage.GetSetting("X"), "X not removed"); PexAssert.AreEqual("Charlie", storage.GetSetting("NAME")); storage.RemoveSetting("NAME"); PexAssert.IsNull(storage.GetSetting("NAME"), "NAME not removed"); }
public void TraversalPUT16() { List <int> list; int[] ints = new int[2]; ints[0] = 1; list = new List <int>((IEnumerable <int>)ints); this.TraversalPUT(list); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(2, list.Capacity); PexAssert.AreEqual <int>(2, list.Count); }
public void InsertAndCurrentAndModify <TPriority, TValue>( [PexAssumeUnderTest] BinaryHeap <TPriority, TValue> target, KeyValuePair <TPriority, TValue> kv) { target.Add(kv.Key, kv.Value); PexAssert.Throws <InvalidOperationException>(delegate { var enumerator = target.GetEnumerator(); target.Add(kv.Key, kv.Value); var current = enumerator.Current; }); }
public void EdgeCapacityGetSet <TVertex, TEdge>( [PexAssumeUnderTest] AdjacencyGraph <TVertex, TEdge> target, int value ) where TEdge : IEdge <TVertex> { // TODO: add assertions to method AdjacencyGraphTVertexTEdgeTest.EdgeCapacityGetSet(AdjacencyGraph`2<!!0,!!1>) target.EdgeCapacity = value; int result = target.EdgeCapacity; PexAssert.AreEqual((object)value, (object)result); }
public void IterationPUT03() { AdjacencyGraph adjacencyGraph; VertexAndEdgeProvider s0 = new VertexAndEdgeProvider(); adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0); ((GenericVertexListGraphTest)this).IterationPUT(adjacencyGraph); PexAssert.IsNotNull((object)adjacencyGraph); PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected); PexAssert.IsNotNull(adjacencyGraph.Provider); PexAssert.IsNotNull(adjacencyGraph.Edges); }
public void WoodFunction(double x1, double x2, double x3, double x4) { if ((10 * (x2 - x1 * x1)) == 0 && (1 - x1) == 0 && (Math.Sqrt(90) * (x4 - x3 * x3)) == 0 && (1 - x3) == 0 && (Math.Sqrt(10) * (x2 + x4 - 2)) == 0 && (Math.Pow(10, -0.5) * (x2 - x4)) == 0) { PexAssert.ReachEventually(); } }
public void IsAssemblyFileTypePUT1([PexAssumeUnderTest] String inpPath) { //PexAssume.IsFalse(inpPath.Contains("\0")); if (inpPath.EndsWith(".dll") || inpPath.EndsWith(".exe")) { PexAssert.IsTrue(PathUtils.IsAssemblyFileType(inpPath)); } else { PexAssert.IsFalse(PathUtils.IsAssemblyFileType(inpPath)); } }
public void InsertionMassivePUT18() { List <int> list; int[] ints = new int[2]; ints[0] = 1; list = new List <int>((IEnumerable <int>)ints); this.InsertionMassivePUT(list); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(2, list.Capacity); PexAssert.AreEqual <int>(2, list.Count); }
public void ClearVertexTargetSource04() { AdjacencyGraph adjacencyGraph; VertexAndEdgeProvider s0 = new VertexAndEdgeProvider(); adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0); ((GenericMutableGraphTestNEW)this).ClearVertexTargetSource(adjacencyGraph); PexAssert.IsNotNull((object)adjacencyGraph); PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected); PexAssert.IsNotNull(adjacencyGraph.Provider); PexAssert.IsNotNull(adjacencyGraph.Edges); }
public void Test_ExtractAll<T>([PexAssumeNotNull] T[] array, T item) where T : IComparable<T> { var seq = OrderedSequence.FromEnumerable(array); var split = seq.ExtractAll(item); Assert2.SequenceEqual(seq, split.Item1.Concat(split.Item2).Concat(split.Item3)); PexAssert.TrueForAll(split.Item1, t => t.CompareTo(item) < 0); PexAssert.TrueForAll(split.Item2, t => t.CompareTo(item) == 0); PexAssert.TrueForAll(split.Item3, t => t.CompareTo(item) > 0); Assert2.SequenceEqual(split.Item1, seq.LessThan(item)); Assert2.SequenceEqual(split.Item1.Concat(split.Item2), seq.AtMost(item)); Assert2.SequenceEqual(split.Item2.Concat(split.Item3), seq.AtLeast(item)); Assert2.SequenceEqual(split.Item3, seq.GreaterThan(item)); }
public void ClearVertexTargetSource03() { AdjacencyGraph adjacencyGraph; VertexAndEdgeProvider s0 = new VertexAndEdgeProvider(); adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, false, 16); this.ClearVertexTargetSource(adjacencyGraph); PexAssert.IsNotNull((object)adjacencyGraph); PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected); PexAssert.IsNotNull(adjacencyGraph.Provider); PexAssert.IsNotNull(adjacencyGraph.Edges); }
public void ContainsTest14() { List <int> list; int[] ints = new int[1]; ints[0] = 1073741824; list = new List <int>((IEnumerable <int>)ints); this.ContainsTest(list, 1); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(1, list.Capacity); PexAssert.AreEqual <int>(1, list.Count); }
public void Return <T>(T value) { var count = 0; var enumerable = EnumerableEx.Return(value); foreach (var res in enumerable) { count++; PexAssert.AreEqual(value, res); } PexAssert.AreEqual(1, count); }
public void CatchDoCatch <T>([PexAssumeNotNull] IEnumerable <T> begin, [PexAssumeNotNull] IEnumerable <T> rest, [PexAssumeNotNull] IEnumerable <T> alternative, bool shouldThrow) { var ex = new InvalidOperationException(); var expectedCaughtCount = shouldThrow ? 1 : 0; var caughtCount = 0; Func <Exception, IEnumerable <T> > replacer = x => { caughtCount++; PexAssert.AreEqual(ex, x); return(alternative); }; var start = begin; if (shouldThrow) { start = start.Concat(EnumerableEx.Throw <T>(ex)); } start = start.Concat(rest); var enumerable = start.Catch(replacer); var enumerator = enumerable.GetEnumerator(); var beginEnumerator = begin.GetEnumerator(); while (beginEnumerator.MoveNext()) { PexAssert.IsTrue(enumerator.MoveNext()); PexAssert.AreEqual(beginEnumerator.Current, enumerator.Current); } if (shouldThrow) { var alternativeEnumerator = alternative.GetEnumerator(); while (alternativeEnumerator.MoveNext()) { PexAssert.IsTrue(enumerator.MoveNext()); PexAssert.AreEqual(alternativeEnumerator.Current, enumerator.Current); } } else { var restEnumerator = rest.GetEnumerator(); while (restEnumerator.MoveNext()) { PexAssert.IsTrue(enumerator.MoveNext()); PexAssert.AreEqual(restEnumerator.Current, enumerator.Current); } } PexAssert.IsFalse(enumerator.MoveNext()); PexAssert.AreEqual(expectedCaughtCount, caughtCount); }
public void NoScript_AnyInput(ErrorMode errorMode, [PexAssumeNotNull] string input) { PexAssume.EnumIsDefined(errorMode); try { var output = BBEncodeForTest(input, errorMode); PexAssert.IsTrue(!output.Contains("<script")); } catch (BBCodeParsingException) { PexAssume.Fail(); } }
public void BadSettingPUT1([PexAssumeUnderTest] SettingsGroup testGroup1, [PexAssumeUnderTest] String settingName, [PexAssumeNotNull] Object settingValue, int defSettingValue) { PexAssume.IsTrue(settingName != null); PexAssume.IsTrue(settingValue != null); //PexAssume.IsTrue(defSettingValue != null); PexAssume.IsTrue(settingValue is string); String str_sv = settingValue as string; PexAssume.IsTrue(Regex.IsMatch(str_sv, "@([a-z])*")); testGroup1.SaveSetting(settingName, settingValue); PexAssert.AreEqual(defSettingValue, testGroup1.GetSetting(settingName, defSettingValue)); }
/// Summary /// Time: 1 min 45 sec /// Pattern: AAAA, Commutative Diagram, AllowedException /// Generalizes two tests "FindMaxTest, FindMaxTreeEmptyTest" into one PUT public void FindMaxTest([PexAssumeUnderTest] int[] elements) { BinarySearchTree <int> bst = new BinarySearchTree <int>(elements); //Compute the maximum element int maxValue = Int32.MinValue; foreach (int val in elements) { maxValue = maxValue < val ? val : maxValue; } PexAssert.AreEqual(maxValue, bst.FindMax()); }
public void ClearPUT21() { List <int> list; int[] ints = new int[3]; ints[0] = 1; ints[2] = 16384; list = new List <int>((IEnumerable <int>)ints); this.ClearPUT(list); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(3, list.Capacity); PexAssert.AreEqual <int>(3, list.Count); }
public void Add_SeveralValues_CountIsIncrementedByCountOfNewValues440() { BinaryHeap <int, int> binaryHeap; binaryHeap = BinaryHeapFactory.Create(); KeyValuePair <int, int>[] keyValuePairs = new KeyValuePair <int, int> [1]; KeyValuePair <int, int> s0 = new KeyValuePair <int, int>(1, default(int)); keyValuePairs[0] = s0; this.Add_SeveralValues_CountIsIncrementedByCountOfNewValues <int, int> (binaryHeap, keyValuePairs); PexAssert.IsNotNull((object)binaryHeap); }
public void RemoveTreePUT26() { List <int> list; int[] ints = new int[3]; ints[0] = 3; ints[1] = 1; list = new List <int>((IEnumerable <int>)ints); this.RemoveTreePUT(list, 0, 0); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(3, list.Capacity); PexAssert.AreEqual <int>(3, list.Count); }
public void FindParentNoItemsInBstTest18() { List <int> list; int[] ints = new int[2]; ints[0] = 1048577; ints[1] = 1; list = new List <int>((IEnumerable <int>)ints); this.FindParentNoItemsInBstTest(list, 0); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(2, list.Capacity); PexAssert.AreEqual <int>(2, list.Count); }
public void CanParseMultipleCategoriesWithAndPUT([PexAssumeUnderTest] CategoryExpression expr) { //CategoryExpression expr = new CategoryExpression("One + Two+Three"); AndFilter andFilter = (AndFilter)expr.Filter; String[] tokens = expr.GetToken().Split('|'); PexAssert.AreEqual(tokens.Length, andFilter.Filters.Length); for (int i = 0; i < andFilter.Filters.Length; i++) { CategoryFilter catFilter = (CategoryFilter)andFilter.Filters[i]; PexAssert.AreEqual(catFilter.Categories, tokens[i]); } }
public void GetEnumeratorTest15() { List <int> list; int[] ints = new int[4]; ints[1] = int.MinValue; ints[3] = 1; list = new List <int>((IEnumerable <int>)ints); this.GetEnumeratorTest(list); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(4, list.Capacity); PexAssert.AreEqual <int>(4, list.Count); }
public void OpenImageOk() { const string fn = "pMin.png"; var f = new OpenImageToBitmap(fn); PexAssert.AreEqual(f.OpenImage().ToStr(), new List <CPoint>() { new CPoint(0, 0), new CPoint(1, 1), new CPoint(12, 35), new CPoint(47, 29), new CPoint(51, 8), new CPoint(29, 17), new CPoint(81, 58) }.ToStr()); }
public void RemoveOutEdgeIf04() { AdjacencyGraph adjacencyGraph; VertexAndEdgeProvider s0 = new VertexAndEdgeProvider(); adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph (s0, PexSafeHelpers.ByteToBoolean((byte)2), 16); this.RemoveOutEdgeIf(adjacencyGraph); PexAssert.IsNotNull((object)adjacencyGraph); PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected); PexAssert.IsNotNull(adjacencyGraph.Provider); PexAssert.IsNotNull(adjacencyGraph.Edges); }
public void FindNodeValidLeftChildTest19() { List <int> list; int[] ints = new int[2]; ints[0] = 536870879; ints[1] = 788529119; list = new List <int>((IEnumerable <int>)ints); this.FindNodeValidLeftChildTest(list, 0, 805306334); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(2, list.Capacity); PexAssert.AreEqual <int>(2, list.Count); }
public void RemoveOutEdgeIf01() { AdjacencyGraph adjacencyGraph; VertexAndEdgeProvider s0 = new VertexAndEdgeProvider(); adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph (s0, PexSafeHelpers.ByteToBoolean((byte)4), 49); ((GenericMutableAdjacencyGraphTest)this).RemoveOutEdgeIf(adjacencyGraph); PexAssert.IsNotNull((object)adjacencyGraph); PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected); PexAssert.IsNotNull(adjacencyGraph.Provider); PexAssert.IsNotNull(adjacencyGraph.Edges); }
public void InsertAndEnumerate <TPriority, TValue>( [PexAssumeUnderTest] BinaryHeap <TPriority, TValue> target, [PexAssumeNotNull] KeyValuePair <TPriority, TValue>[] kvs) { var dic = new Dictionary <TPriority, TValue>(); foreach (var kv in kvs) { target.Add(kv.Key, kv.Value); dic[kv.Key] = kv.Value; } PexAssert.TrueForAll(target, kv => dic.ContainsKey(kv.Key)); }
public void FindNodeValidLeftChildTest18() { List <int> list; int[] ints = new int[2]; ints[0] = 131073; ints[1] = 1; list = new List <int>((IEnumerable <int>)ints); this.FindNodeValidLeftChildTest(list, 0, 0); PexAssert.IsNotNull((object)list); PexAssert.AreEqual <int>(2, list.Capacity); PexAssert.AreEqual <int>(2, list.Count); }