public static void SortedDictionary_GetEnumeratorTest_Negative() { Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(); RefX1 <int>[] intArr = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr[i] = new RefX1 <int>(i); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(); ValX1 <string>[] stringArr = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } //Ref<Val>,Val<Ref> IntDriver.GetEnumeratorValidations(intArr, stringArr, new RefX1 <int>(1000), new ValX1 <string>("1000")); IntDriver.GetEnumeratorValidations(new RefX1 <int> [0], new ValX1 <string> [0], new RefX1 <int>(1000), new ValX1 <string>("1000")); //Val<Ref>,Ref<Val> StringDriver.GetEnumeratorValidations(new ValX1 <string> [0], new RefX1 <int> [0], new ValX1 <string>("1000"), new RefX1 <int>(1000)); }
public static void SortedDictionary_RemoveIntTest() { Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(); RefX1 <int>[] intArr1 = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr1[i] = new RefX1 <int>(i); } RefX1 <int>[] intArr2 = new RefX1 <int> [10]; for (int i = 0; i < 10; i++) { intArr2[i] = new RefX1 <int>(i + 100); } ValX1 <string>[] stringArr1 = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr1[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } //Ref<val>,Val<Ref> IntDriver.BasicRemove(intArr1, stringArr1); IntDriver.RemoveNegative(intArr1, stringArr1, intArr2); IntDriver.RemoveNegative(new RefX1 <int>[] { }, new ValX1 <string>[] { }, intArr2); IntDriver.RemoveSameKey(intArr1, stringArr1, 0, 2); IntDriver.RemoveSameKey(intArr1, stringArr1, 99, 3); IntDriver.RemoveSameKey(intArr1, stringArr1, 50, 4); IntDriver.RemoveSameKey(intArr1, stringArr1, 1, 5); IntDriver.RemoveSameKey(intArr1, stringArr1, 98, 6); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 0, 2); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 99, 3); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 50, 4); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 1, 5); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 98, 6); IntDriver.NonGenericIDictionaryBasicRemove(intArr1, stringArr1); IntDriver.NonGenericIDictionaryRemoveNegative(intArr1, stringArr1, intArr2); IntDriver.NonGenericIDictionaryRemoveNegative(new RefX1 <int>[] { }, new ValX1 <string>[] { }, intArr2); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 0, 2); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 99, 3); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 50, 4); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 1, 5); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 98, 6); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 0, 2); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 99, 3); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 50, 4); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 1, 5); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 98, 6); }
public override bool Equals(object obj) { RefX1 <T> b = obj as RefX1 <T>; if (b == null) { return(false); } return(this._val.Equals(b._val)); }
public static void SortedDictionary_ConatinsValueTest() { Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(); RefX1 <int>[] intArr1 = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr1[i] = new RefX1 <int>(i); } RefX1 <int>[] intArr2 = new RefX1 <int> [10]; for (int i = 0; i < 10; i++) { intArr2[i] = new RefX1 <int>(i + 100); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(); ValX1 <string>[] stringArr1 = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr1[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } ValX1 <string>[] stringArr2 = new ValX1 <string> [10]; for (int i = 0; i < 10; i++) { stringArr2[i] = new ValX1 <string>("SomeTestString" + (i + 100).ToString()); } //Ref<val>,Val<Ref> IntDriver.BasicContainsValue(intArr1, stringArr1); IntDriver.ContainsValueNegative(intArr1, stringArr1, stringArr2); IntDriver.ContainsValueNegative(new RefX1 <int>[] { }, new ValX1 <string>[] { }, stringArr2); IntDriver.AddRemoveKeyContainsValue(intArr1, stringArr1, 0); IntDriver.AddRemoveKeyContainsValue(intArr1, stringArr1, 50); IntDriver.AddRemoveKeyContainsValue(intArr1, stringArr1, 99); IntDriver.AddRemoveAddKeyContainsValue(intArr1, stringArr1, 0, 1); IntDriver.AddRemoveAddKeyContainsValue(intArr1, stringArr1, 50, 2); IntDriver.AddRemoveAddKeyContainsValue(intArr1, stringArr1, 99, 3); //Val<Ref>,Ref<Val> StringDriver.BasicContainsValue(stringArr1, intArr1); StringDriver.BasicContainsValue(new ValX1 <string>[] { new ValX1 <string>("str") }, new RefX1 <int>[] { null }); StringDriver.ContainsValueNegative(stringArr1, intArr1, intArr2); StringDriver.ContainsValueNegative(new ValX1 <string>[] { }, new RefX1 <int>[] { }, intArr2); StringDriver.ContainsValueNegative(new ValX1 <string>[] { }, new RefX1 <int>[] { }, new RefX1 <int>[] { null }); StringDriver.AddRemoveKeyContainsValue(stringArr1, intArr1, 0); StringDriver.AddRemoveKeyContainsValue(stringArr1, intArr1, 50); StringDriver.AddRemoveKeyContainsValue(stringArr1, intArr1, 99); StringDriver.AddRemoveAddKeyContainsValue(stringArr1, intArr1, 0, 1); StringDriver.AddRemoveAddKeyContainsValue(stringArr1, intArr1, 50, 2); StringDriver.AddRemoveAddKeyContainsValue(stringArr1, intArr1, 99, 3); }
public static void ClearMain() { Test test = new Test(); Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(test); RefX1 <int>[] intArr = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr[i] = new RefX1 <int>(i); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(test); ValX1 <string>[] stringArr = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } IntDriver.Clear(intArr, stringArr, 1); IntDriver.Clear(intArr, stringArr, 10); IntDriver.Clear(new RefX1 <int>[] { }, new ValX1 <string>[] { }, 1); IntDriver.Clear(new RefX1 <int>[] { }, new ValX1 <string>[] { }, 10); StringDriver.Clear(stringArr, intArr, 1); StringDriver.Clear(stringArr, intArr, 10); StringDriver.Clear(new ValX1 <string>[] { }, new RefX1 <int>[] { }, 1); StringDriver.Clear(new ValX1 <string>[] { }, new RefX1 <int>[] { }, 10); IntDriver.NonGenericIDictionaryClear(intArr, stringArr, 1); IntDriver.NonGenericIDictionaryClear(intArr, stringArr, 10); IntDriver.NonGenericIDictionaryClear(new RefX1 <int>[] { }, new ValX1 <string>[] { }, 1); IntDriver.NonGenericIDictionaryClear(new RefX1 <int>[] { }, new ValX1 <string>[] { }, 10); StringDriver.NonGenericIDictionaryClear(stringArr, intArr, 1); StringDriver.NonGenericIDictionaryClear(stringArr, intArr, 10); StringDriver.NonGenericIDictionaryClear(new ValX1 <string>[] { }, new RefX1 <int>[] { }, 1); StringDriver.NonGenericIDictionaryClear(new ValX1 <string>[] { }, new RefX1 <int>[] { }, 10); Assert.True(test.result); }
public static void CopyToMain() { Test test = new Test(); Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(test); RefX1 <int>[] intArr = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr[i] = new RefX1 <int>(i); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(test); ValX1 <string>[] stringArr = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } //Ref<val>,Val<Ref> IntDriver.BasicCopyTo <SpecificException>(intArr, stringArr, new System.Collections.Generic.KeyValuePair <RefX1 <int>, ValX1 <string> > [100], 0, false); IntDriver.BasicCopyTo <SpecificException>(new RefX1 <int>[] { }, new ValX1 <string>[] { }, new System.Collections.Generic.KeyValuePair <RefX1 <int>, ValX1 <string> > [0], 0, false); IntDriver.BasicCopyTo <ArgumentOutOfRangeException>(intArr, stringArr, new System.Collections.Generic.KeyValuePair <RefX1 <int>, ValX1 <string> > [100], -1, true); IntDriver.BasicCopyTo <ArgumentNullException>(intArr, stringArr, null, 0, true); IntDriver.BasicCopyTo <ArgumentException>(intArr, stringArr, new System.Collections.Generic.KeyValuePair <RefX1 <int>, ValX1 <string> > [100], 1, true); //IntDriver.BasicCopyTo<ArgumentException>(intArr,stringArr,new System.Collections.Generic.KeyValuePair<RefX1<int>,ValX1<string>>[100,1],0,true); //IntDriver.BasicCopyTo<ArrayTypeMismatchException>(intArr,stringArr,new int[100],0,true); //Val<Ref>,Ref<Val> StringDriver.BasicCopyTo <SpecificException>(stringArr, intArr, new System.Collections.Generic.KeyValuePair <ValX1 <string>, RefX1 <int> > [100], 0, false); StringDriver.BasicCopyTo <SpecificException>(new ValX1 <string>[] { }, new RefX1 <int>[] { }, new System.Collections.Generic.KeyValuePair <ValX1 <string>, RefX1 <int> > [0], 0, false); //StringDriver.BasicCopyTo<ArrayTypeMismatchException>(stringArr,intArr,new string[100],0,true); Assert.True(test.result); }
public static void SortedDictionary_ClearTest() { Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(); RefX1 <int>[] intArr = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr[i] = new RefX1 <int>(i); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(); ValX1 <string>[] stringArr = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } IntDriver.Clear(intArr, stringArr, 1); IntDriver.Clear(intArr, stringArr, 10); IntDriver.Clear(new RefX1 <int>[] { }, new ValX1 <string>[] { }, 1); IntDriver.Clear(new RefX1 <int>[] { }, new ValX1 <string>[] { }, 10); StringDriver.Clear(stringArr, intArr, 1); StringDriver.Clear(stringArr, intArr, 10); StringDriver.Clear(new ValX1 <string>[] { }, new RefX1 <int>[] { }, 1); StringDriver.Clear(new ValX1 <string>[] { }, new RefX1 <int>[] { }, 10); IntDriver.NonGenericIDictionaryClear(intArr, stringArr, 1); IntDriver.NonGenericIDictionaryClear(intArr, stringArr, 10); IntDriver.NonGenericIDictionaryClear(new RefX1 <int>[] { }, new ValX1 <string>[] { }, 1); IntDriver.NonGenericIDictionaryClear(new RefX1 <int>[] { }, new ValX1 <string>[] { }, 10); StringDriver.NonGenericIDictionaryClear(stringArr, intArr, 1); StringDriver.NonGenericIDictionaryClear(stringArr, intArr, 10); StringDriver.NonGenericIDictionaryClear(new ValX1 <string>[] { }, new RefX1 <int>[] { }, 1); StringDriver.NonGenericIDictionaryClear(new ValX1 <string>[] { }, new RefX1 <int>[] { }, 10); }
public static void SortedDictionary_RemoveTest_Negative() { Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(); Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(); RefX1 <int>[] intArr1 = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr1[i] = new RefX1 <int>(i); } ValX1 <string>[] stringArr1 = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr1[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } IntDriver.NonGenericIDictionaryRemoveValidations(intArr1, stringArr1); IntDriver.NonGenericIDictionaryRemoveValidations(new RefX1 <int>[] { }, new ValX1 <string>[] { }); StringDriver.NonGenericIDictionaryRemoveValidations(stringArr1, intArr1); StringDriver.NonGenericIDictionaryRemoveValidations(new ValX1 <string>[] { }, new RefX1 <int>[] { }); }
public static void NoGenIEnumMain() { Test test = new Test(); Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(test); RefX1 <int>[] intArr = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr[i] = new RefX1 <int>(i); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(test); ValX1 <string>[] stringArr = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } //Ref<Val>,Val<Ref> IntDriver.GetEnumeratorBasic(intArr, stringArr); IntDriver.GetEnumeratorBasic(new RefX1 <int> [0], new ValX1 <string> [0]); IntDriver.GetEnumeratorValidations(intArr, stringArr, new RefX1 <int>(1000), new ValX1 <string>("1000")); IntDriver.GetEnumeratorValidations(new RefX1 <int> [0], new ValX1 <string> [0], new RefX1 <int>(1000), new ValX1 <string>("1000")); //Val<Ref>,Ref<Val> StringDriver.GetEnumeratorBasic(stringArr, intArr); StringDriver.GetEnumeratorBasic(new ValX1 <string> [0], new RefX1 <int> [0]); StringDriver.GetEnumeratorValidations(stringArr, intArr, new ValX1 <string>("1000"), new RefX1 <int>(1000)); StringDriver.GetEnumeratorValidations(new ValX1 <string> [0], new RefX1 <int> [0], new ValX1 <string>("1000"), new RefX1 <int>(1000)); Assert.True(test.result); }
public static void ContainKeyMain() { Test test = new Test(); Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(test); RefX1 <int>[] intArr1 = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr1[i] = new RefX1 <int>(i); } RefX1 <int>[] intArr2 = new RefX1 <int> [10]; for (int i = 0; i < 10; i++) { intArr2[i] = new RefX1 <int>(i + 100); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(test); ValX1 <string>[] stringArr1 = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr1[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } ValX1 <string>[] stringArr2 = new ValX1 <string> [10]; for (int i = 0; i < 10; i++) { stringArr2[i] = new ValX1 <string>("SomeTestString" + (i + 100).ToString()); } //Ref<val>,Val<Ref> IntDriver.BasicContainsKey(intArr1, stringArr1); IntDriver.ContainsKeyNegative(intArr1, stringArr1, intArr2); IntDriver.ContainsKeyNegative(new RefX1 <int>[] { }, new ValX1 <string>[] { }, intArr2); IntDriver.AddRemoveKeyContainsKey(intArr1, stringArr1, 0); IntDriver.AddRemoveKeyContainsKey(intArr1, stringArr1, 50); IntDriver.AddRemoveKeyContainsKey(intArr1, stringArr1, 99); IntDriver.AddRemoveAddKeyContainsKey(intArr1, stringArr1, 0, 1); IntDriver.AddRemoveAddKeyContainsKey(intArr1, stringArr1, 50, 2); IntDriver.AddRemoveAddKeyContainsKey(intArr1, stringArr1, 99, 3); IntDriver.ContainsKeyValidationsRefType(intArr1, stringArr1); IntDriver.ContainsKeyValidationsRefType(new RefX1 <int>[] { }, new ValX1 <string>[] { }); //Val<Ref>,Ref<Val> StringDriver.BasicContainsKey(stringArr1, intArr1); StringDriver.ContainsKeyNegative(stringArr1, intArr1, stringArr2); StringDriver.ContainsKeyNegative(new ValX1 <string>[] { }, new RefX1 <int>[] { }, stringArr2); StringDriver.AddRemoveKeyContainsKey(stringArr1, intArr1, 0); StringDriver.AddRemoveKeyContainsKey(stringArr1, intArr1, 50); StringDriver.AddRemoveKeyContainsKey(stringArr1, intArr1, 99); StringDriver.AddRemoveAddKeyContainsKey(stringArr1, intArr1, 0, 1); StringDriver.AddRemoveAddKeyContainsKey(stringArr1, intArr1, 50, 2); StringDriver.AddRemoveAddKeyContainsKey(stringArr1, intArr1, 99, 3); Assert.True(test.result); }
public void _Init(RefX1 <int> fld1) { Fld1 = fld1; }
public override void _Init(RefX1 <int> fld1) { Fld1 = fld1; }
public static void RunTests() { Driver <RefX1 <int> > IntDriver = new Driver <RefX1 <int> >(); RefX1 <int>[] intArr = new RefX1 <int> [100]; RefX1 <int>[] intArrToRemove = new RefX1 <int> [50]; RefX1 <int>[] intArrAfterRemove = new RefX1 <int> [50]; RefX1IntGenerator refX1IntGenerator = new RefX1IntGenerator(); for (int i = 0; i < 100; i++) { intArr[i] = refX1IntGenerator.NextValue(); if ((i & 1) != 0) { intArrToRemove[i / 2] = intArr[i]; } else { intArrAfterRemove[i / 2] = intArr[i]; } } IntDriver.CheckType(); IntDriver.EmptyCollection(refX1IntGenerator.NextValue); IntDriver.NonEmptyCollectionIEnumerableCtor(intArr, refX1IntGenerator.NextValue); IntDriver.NonEmptyCollectionAdd(intArr, refX1IntGenerator.NextValue); IntDriver.AddRemoveSome(intArrAfterRemove, intArr, intArrToRemove, refX1IntGenerator.NextValue); IntDriver.AddRemoveAll(intArr, refX1IntGenerator.NextValue); IntDriver.AddClear(intArr, refX1IntGenerator.NextValue); Driver <ValX1 <String> > StringDriver = new Driver <ValX1 <String> >(); ValX1 <String>[] StringArr = new ValX1 <String> [100]; ValX1 <String>[] StringArrToRemove = new ValX1 <String> [50]; ValX1 <String>[] StringArrAfterRemove = new ValX1 <String> [50]; ValX1StringGenerator valX1StringGenerator = new ValX1StringGenerator(); for (int i = 0; i < 100; i++) { StringArr[i] = valX1StringGenerator.NextValue(); if ((i & 1) != 0) { StringArrToRemove[i / 2] = StringArr[i]; } else { StringArrAfterRemove[i / 2] = StringArr[i]; } } StringDriver.CheckType(); StringDriver.EmptyCollection(valX1StringGenerator.NextValue); StringDriver.NonEmptyCollectionIEnumerableCtor(StringArr, valX1StringGenerator.NextValue); StringDriver.NonEmptyCollectionAdd(StringArr, valX1StringGenerator.NextValue); StringDriver.AddRemoveSome(StringArrAfterRemove, StringArr, StringArrToRemove, valX1StringGenerator.NextValue); StringDriver.AddRemoveAll(StringArr, valX1StringGenerator.NextValue); StringDriver.AddClear(StringArr, valX1StringGenerator.NextValue); Assert.True(List_ListUtils.Test.result); }
public static void IndexOfKeyMain() { Test test = new Test(); Driver <RefX1 <int>, ValX1 <string>, int, string> IntDriver = new Driver <RefX1 <int>, ValX1 <string>, int, string>(test); RefX1 <int>[] intArr1 = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr1[i] = new RefX1 <int>(i); } RefX1 <int>[] intArr2 = new RefX1 <int> [15]; for (int i = 0; i < 10; i++) { intArr2[i] = new RefX1 <int>(i + 200); } for (int i = 10; i < 15; i++) { intArr2[i] = new RefX1 <int>(i + 195); } Driver <ValX1 <string>, RefX1 <int>, string, int> StringDriver = new Driver <ValX1 <string>, RefX1 <int>, string, int>(test); ValX1 <string>[] stringArr1 = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr1[i] = new ValX1 <string>("SomeTestString" + (i + 100).ToString()); } ValX1 <string>[] stringArr2 = new ValX1 <string> [15]; for (int i = 0; i < 10; i++) { stringArr2[i] = new ValX1 <string>("SomeTestString" + (i + 200)); } for (int i = 10; i < 15; i++) { stringArr2[i] = new ValX1 <string>("SomeTestString" + (i + 195)); } //Ref<val>,Val<Ref> IntDriver.BasicIndexOfKey(intArr1, stringArr1); Assert.True(test.result); IntDriver.IndexOfKeyNegative(intArr1, stringArr1, intArr2); IntDriver.IndexOfKeyNegative(new RefX1 <int> [0], new ValX1 <string> [0], intArr2); IntDriver.AddRemoveKeyIndexOfKey(intArr1, stringArr1, 0); IntDriver.AddRemoveKeyIndexOfKey(intArr1, stringArr1, 50); IntDriver.AddRemoveKeyIndexOfKey(intArr1, stringArr1, 99); //Val<Ref>,Ref<Val> StringDriver.BasicIndexOfKey(stringArr1, intArr1); StringDriver.IndexOfKeyNegative(stringArr1, intArr1, stringArr2); StringDriver.AddRemoveKeyIndexOfKey(stringArr1, intArr1, 0); StringDriver.AddRemoveKeyIndexOfKey(stringArr1, intArr1, 50); StringDriver.AddRemoveKeyIndexOfKey(stringArr1, intArr1, 99); intArr1 = new RefX1 <int> [105]; for (int i = 0; i < 105; i++) { intArr1[i] = new RefX1 <int>(i); } RefX1 <int>[] intArr3 = new RefX1 <int> [15]; for (int i = 0; i < 10; i++) { intArr3[i] = new RefX1 <int>(i + 100); } for (int i = 10; i < 15; i++) { intArr3[i] = new RefX1 <int>(101); } stringArr1 = new ValX1 <string> [105]; for (int i = 0; i < 100; i++) { stringArr1[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } for (int i = 100; i < 105; i++) { stringArr1[i] = new ValX1 <string>("SomeTestString11"); } stringArr2 = new ValX1 <string> [15]; for (int i = 0; i < 15; i++) { stringArr2[i] = new ValX1 <string>("SomeTestString" + (i + 100).ToString()); } IntDriver.BasicIndexOfKey(intArr1, stringArr1); StringDriver.BasicIndexOfKey(stringArr2, intArr3); Assert.True(test.result); }
public static void MainAdd() { Test test = new Test(); Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(test); RefX1 <int>[] intArr = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr[i] = new RefX1 <int>(i); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(test); ValX1 <string>[] stringArr = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } //Ref<val>,Val<Ref> IntDriver.BasicAdd(intArr, stringArr); IntDriver.AddSameKey(intArr, stringArr, 0, 2); IntDriver.AddSameKey(intArr, stringArr, 99, 3); IntDriver.AddSameKey(intArr, stringArr, 50, 4); IntDriver.AddSameKey(intArr, stringArr, 1, 5); IntDriver.AddSameKey(intArr, stringArr, 98, 6); IntDriver.AddRemoveKeyValPair(intArr, stringArr, 0, 2); IntDriver.AddRemoveKeyValPair(intArr, stringArr, 99, 3); IntDriver.AddRemoveKeyValPair(intArr, stringArr, 50, 4); IntDriver.AddRemoveKeyValPair(intArr, stringArr, 1, 5); IntDriver.AddRemoveKeyValPair(intArr, stringArr, 98, 6); IntDriver.AddValidations(intArr, stringArr, null, stringArr[0]); IntDriver.AddValidations(new RefX1 <int>[] { }, new ValX1 <string>[] { }, null, stringArr[0]); IntDriver.NonGenericIDictionaryBasicAdd(intArr, stringArr); IntDriver.NonGenericIDictionaryAddSameKey(intArr, stringArr, 0, 2); IntDriver.NonGenericIDictionaryAddSameKey(intArr, stringArr, 99, 3); IntDriver.NonGenericIDictionaryAddSameKey(intArr, stringArr, 50, 4); IntDriver.NonGenericIDictionaryAddSameKey(intArr, stringArr, 1, 5); IntDriver.NonGenericIDictionaryAddSameKey(intArr, stringArr, 98, 6); IntDriver.NonGenericIDictionaryAddRemoveKeyValPair(intArr, stringArr, 0, 2); IntDriver.NonGenericIDictionaryAddRemoveKeyValPair(intArr, stringArr, 99, 3); IntDriver.NonGenericIDictionaryAddRemoveKeyValPair(intArr, stringArr, 50, 4); IntDriver.NonGenericIDictionaryAddRemoveKeyValPair(intArr, stringArr, 1, 5); IntDriver.NonGenericIDictionaryAddRemoveKeyValPair(intArr, stringArr, 98, 6); IntDriver.NonGenericIDictionaryAddValidations(intArr, stringArr, null, stringArr[0]); IntDriver.NonGenericIDictionaryAddValidations(new RefX1 <int>[] { }, new ValX1 <string>[] { }, null, stringArr[0]); //Val<Ref>,Ref<Val> StringDriver.BasicAdd(stringArr, intArr); StringDriver.AddSameKey(stringArr, intArr, 0, 2); StringDriver.AddSameKey(stringArr, intArr, 99, 3); StringDriver.AddSameKey(stringArr, intArr, 50, 4); StringDriver.AddSameKey(stringArr, intArr, 1, 5); StringDriver.AddSameKey(stringArr, intArr, 98, 6); StringDriver.AddRemoveKeyValPair(stringArr, intArr, 0, 2); StringDriver.AddRemoveKeyValPair(stringArr, intArr, 99, 3); StringDriver.AddRemoveKeyValPair(stringArr, intArr, 50, 4); StringDriver.AddRemoveKeyValPair(stringArr, intArr, 1, 5); StringDriver.AddRemoveKeyValPair(stringArr, intArr, 98, 6); StringDriver.AddValidations(stringArr, intArr, stringArr[0], intArr[0]); StringDriver.AddValidations(new ValX1 <string>[] { }, new RefX1 <int>[] { }, stringArr[0], intArr[0]); StringDriver.NonGenericIDictionaryBasicAdd(stringArr, intArr); StringDriver.NonGenericIDictionaryAddSameKey(stringArr, intArr, 0, 2); StringDriver.NonGenericIDictionaryAddSameKey(stringArr, intArr, 99, 3); StringDriver.NonGenericIDictionaryAddSameKey(stringArr, intArr, 50, 4); StringDriver.NonGenericIDictionaryAddSameKey(stringArr, intArr, 1, 5); StringDriver.NonGenericIDictionaryAddSameKey(stringArr, intArr, 98, 6); StringDriver.NonGenericIDictionaryAddRemoveKeyValPair(stringArr, intArr, 0, 2); StringDriver.NonGenericIDictionaryAddRemoveKeyValPair(stringArr, intArr, 99, 3); StringDriver.NonGenericIDictionaryAddRemoveKeyValPair(stringArr, intArr, 50, 4); StringDriver.NonGenericIDictionaryAddRemoveKeyValPair(stringArr, intArr, 1, 5); StringDriver.NonGenericIDictionaryAddRemoveKeyValPair(stringArr, intArr, 98, 6); StringDriver.NonGenericIDictionaryAddValidations(stringArr, intArr, stringArr[0], intArr[0]); StringDriver.NonGenericIDictionaryAddValidations(new ValX1 <string>[] { }, new RefX1 <int>[] { }, stringArr[0], intArr[0]); Assert.True(test.result); }
public static int Main() { Random r = new Random(); try { // test for ConditionalWeakTable<string> Driver <string, string> stringDriver = new Driver <string, string>(); string[] stringArr = new string[100]; for (int i = 0; i < 100; i++) { stringArr[i] = "SomeTestString" + i.ToString(); } // test with generic object // test for ConditionalWeakTable<RefX1<int>> Driver <string, RefX1 <int> > refIntDriver = new Driver <string, RefX1 <int> >(); RefX1 <int>[] refIntArr = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { refIntArr[i] = new RefX1 <int>(i); } // test with generic object // test for ConditionalWeakTable<RefX1<string>> Driver <string, RefX1 <string> > refStringDriver = new Driver <string, RefX1 <string> >(); RefX1 <string>[] refStringArr = new RefX1 <string> [100]; for (int i = 0; i < 100; i++) { refStringArr[i] = new RefX1 <string>("SomeTestString" + i.ToString()); } stringDriver.BasicAdd(stringArr, stringArr); refIntDriver.BasicAdd(stringArr, refIntArr); refStringDriver.BasicAdd(stringArr, refStringArr); //=============================================================== // test various boundary conditions // - add/remove/lookup of null key // - remove/lookup of non-existing key in an empty dictionary and a non-empty dictionary stringDriver.AddValidations(stringArr, stringArr, stringArr[0]); refIntDriver.AddValidations(stringArr, refIntArr, refIntArr[0]); refStringDriver.AddValidations(stringArr, refStringArr, refStringArr[0]); //=============================================================== stringDriver.RemoveValidations(stringArr, stringArr, r.Next().ToString(), stringArr[0]); refIntDriver.RemoveValidations(stringArr, refIntArr, r.Next().ToString(), refIntArr[0]); refStringDriver.RemoveValidations(stringArr, refStringArr, r.Next().ToString(), refStringArr[0]); //=============================================================== stringDriver.TryGetValueValidations(stringArr, stringArr, r.Next().ToString(), stringArr[0]); refIntDriver.TryGetValueValidations(stringArr, refIntArr, r.Next().ToString(), refIntArr[0]); refStringDriver.TryGetValueValidations(stringArr, refStringArr, r.Next().ToString(), refStringArr[0]); //=============================================================== // this method generates a dictionary with keys and values to be used for GetValue() method testing stringDriver.GenerateValuesForStringKeys(stringArr); stringDriver.GetValueValidations(stringArr, stringArr); Driver <RefX1 <int>, string> refIntDriver2 = new Driver <RefX1 <int>, string>(); refIntDriver2.GenerateValuesForIntRefKeys(refIntArr, stringArr); refIntDriver2.GetValueValidations(refIntArr, stringArr); Driver <RefX1 <string>, string> refStringDriver2 = new Driver <RefX1 <string>, string>(); refStringDriver2.GenerateValuesForStringRefKeys(refStringArr, stringArr); refStringDriver2.GetValueValidations(refStringArr, stringArr); //=============================================================== stringDriver.AddSameKey(stringArr, stringArr, 0, 2); stringDriver.AddSameKey(stringArr, stringArr, 99, 3); stringDriver.AddSameKey(stringArr, stringArr, 50, 4); stringDriver.AddSameKey(stringArr, stringArr, 1, 5); stringDriver.AddSameKey(stringArr, stringArr, 98, 6); refIntDriver.AddSameKey(stringArr, refIntArr, 0, 2); refIntDriver.AddSameKey(stringArr, refIntArr, 99, 3); refIntDriver.AddSameKey(stringArr, refIntArr, 50, 4); refIntDriver.AddSameKey(stringArr, refIntArr, 1, 5); refIntDriver.AddSameKey(stringArr, refIntArr, 98, 6); refStringDriver.AddSameKey(stringArr, refStringArr, 0, 2); refStringDriver.AddSameKey(stringArr, refStringArr, 99, 3); refStringDriver.AddSameKey(stringArr, refStringArr, 50, 4); refStringDriver.AddSameKey(stringArr, refStringArr, 1, 5); refStringDriver.AddSameKey(stringArr, refStringArr, 98, 6); //=============================================================== stringDriver.AddRemoveKeyValPair(stringArr, stringArr, 0, 2); stringDriver.AddRemoveKeyValPair(stringArr, stringArr, 99, 3); stringDriver.AddRemoveKeyValPair(stringArr, stringArr, 50, 4); stringDriver.AddRemoveKeyValPair(stringArr, stringArr, 1, 5); stringDriver.AddRemoveKeyValPair(stringArr, stringArr, 98, 6); refIntDriver.AddRemoveKeyValPair(stringArr, refIntArr, 0, 2); refIntDriver.AddRemoveKeyValPair(stringArr, refIntArr, 99, 3); refIntDriver.AddRemoveKeyValPair(stringArr, refIntArr, 50, 4); refIntDriver.AddRemoveKeyValPair(stringArr, refIntArr, 1, 5); refIntDriver.AddRemoveKeyValPair(stringArr, refIntArr, 98, 6); refStringDriver.AddRemoveKeyValPair(stringArr, refStringArr, 0, 2); refStringDriver.AddRemoveKeyValPair(stringArr, refStringArr, 99, 3); refStringDriver.AddRemoveKeyValPair(stringArr, refStringArr, 50, 4); refStringDriver.AddRemoveKeyValPair(stringArr, refStringArr, 1, 5); refStringDriver.AddRemoveKeyValPair(stringArr, refStringArr, 98, 6); //============================================================== // new tests for GetOrCreateValue (new Driver <string, WithDefaultConstructor>()).BasicGetOrCreateValue(stringArr); WithDefaultConstructor[] wvalues = new WithDefaultConstructor[stringArr.Length]; for (int i = 0; i < wvalues.Length; i++) { wvalues[i] = new WithDefaultConstructor(stringArr[i]); } (new Driver <string, WithDefaultConstructor>()).BasicAddThenGetOrCreateValue(stringArr, wvalues); NegativeTestCases.NoDefaulConstructor(); //=============================================================== if (Test.result) { Console.WriteLine("Test Passed"); return(100); } else { Console.WriteLine("Test Failed"); return(101); } } catch (Exception e) { Console.WriteLine("Test threw unexpected exception:\n{0}", e); return(102); } }
public static void RemoveMain() { Test test = new Test(); Driver <RefX1 <int>, ValX1 <string> > IntDriver = new Driver <RefX1 <int>, ValX1 <string> >(test); RefX1 <int>[] intArr1 = new RefX1 <int> [100]; for (int i = 0; i < 100; i++) { intArr1[i] = new RefX1 <int>(i); } RefX1 <int>[] intArr2 = new RefX1 <int> [10]; for (int i = 0; i < 10; i++) { intArr2[i] = new RefX1 <int>(i + 100); } Driver <ValX1 <string>, RefX1 <int> > StringDriver = new Driver <ValX1 <string>, RefX1 <int> >(test); ValX1 <string>[] stringArr1 = new ValX1 <string> [100]; for (int i = 0; i < 100; i++) { stringArr1[i] = new ValX1 <string>("SomeTestString" + i.ToString()); } ValX1 <string>[] stringArr2 = new ValX1 <string> [10]; for (int i = 0; i < 10; i++) { stringArr2[i] = new ValX1 <string>("SomeTestString" + (i + 100).ToString()); } //Ref<val>,Val<Ref> IntDriver.BasicRemove(intArr1, stringArr1); IntDriver.RemoveNegative(intArr1, stringArr1, intArr2); IntDriver.RemoveNegative(new RefX1 <int>[] { }, new ValX1 <string>[] { }, intArr2); IntDriver.RemoveSameKey(intArr1, stringArr1, 0, 2); IntDriver.RemoveSameKey(intArr1, stringArr1, 99, 3); IntDriver.RemoveSameKey(intArr1, stringArr1, 50, 4); IntDriver.RemoveSameKey(intArr1, stringArr1, 1, 5); IntDriver.RemoveSameKey(intArr1, stringArr1, 98, 6); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 0, 2); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 99, 3); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 50, 4); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 1, 5); IntDriver.AddRemoveSameKey(intArr1, stringArr1, 98, 6); IntDriver.RemoveValidationsRefType(intArr1, stringArr1); IntDriver.RemoveValidationsRefType(new RefX1 <int>[] { }, new ValX1 <string>[] { }); IntDriver.NonGenericIDictionaryBasicRemove(intArr1, stringArr1); IntDriver.NonGenericIDictionaryRemoveNegative(intArr1, stringArr1, intArr2); IntDriver.NonGenericIDictionaryRemoveNegative(new RefX1 <int>[] { }, new ValX1 <string>[] { }, intArr2); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 0, 2); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 99, 3); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 50, 4); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 1, 5); IntDriver.NonGenericIDictionaryRemoveSameKey(intArr1, stringArr1, 98, 6); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 0, 2); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 99, 3); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 50, 4); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 1, 5); IntDriver.NonGenericIDictionaryAddRemoveSameKey(intArr1, stringArr1, 98, 6); IntDriver.NonGenericIDictionaryRemoveValidations(intArr1, stringArr1); IntDriver.NonGenericIDictionaryRemoveValidations(new RefX1 <int>[] { }, new ValX1 <string>[] { }); //Val<Ref>,Ref<Val> StringDriver.BasicRemove(stringArr1, intArr1); StringDriver.RemoveNegative(stringArr1, intArr1, stringArr2); StringDriver.RemoveNegative(new ValX1 <string>[] { }, new RefX1 <int>[] { }, stringArr2); StringDriver.RemoveSameKey(stringArr1, intArr1, 0, 2); StringDriver.RemoveSameKey(stringArr1, intArr1, 99, 3); StringDriver.RemoveSameKey(stringArr1, intArr1, 50, 4); StringDriver.RemoveSameKey(stringArr1, intArr1, 1, 5); StringDriver.RemoveSameKey(stringArr1, intArr1, 98, 6); StringDriver.AddRemoveSameKey(stringArr1, intArr1, 0, 2); StringDriver.AddRemoveSameKey(stringArr1, intArr1, 99, 3); StringDriver.AddRemoveSameKey(stringArr1, intArr1, 50, 4); StringDriver.AddRemoveSameKey(stringArr1, intArr1, 1, 5); StringDriver.AddRemoveSameKey(stringArr1, intArr1, 98, 6); StringDriver.NonGenericIDictionaryBasicRemove(stringArr1, intArr1); StringDriver.NonGenericIDictionaryRemoveNegative(stringArr1, intArr1, stringArr2); StringDriver.NonGenericIDictionaryRemoveNegative(new ValX1 <string>[] { }, new RefX1 <int>[] { }, stringArr2); StringDriver.NonGenericIDictionaryRemoveSameKey(stringArr1, intArr1, 0, 2); StringDriver.NonGenericIDictionaryRemoveSameKey(stringArr1, intArr1, 99, 3); StringDriver.NonGenericIDictionaryRemoveSameKey(stringArr1, intArr1, 50, 4); StringDriver.NonGenericIDictionaryRemoveSameKey(stringArr1, intArr1, 1, 5); StringDriver.NonGenericIDictionaryRemoveSameKey(stringArr1, intArr1, 98, 6); StringDriver.NonGenericIDictionaryAddRemoveSameKey(stringArr1, intArr1, 0, 2); StringDriver.NonGenericIDictionaryAddRemoveSameKey(stringArr1, intArr1, 99, 3); StringDriver.NonGenericIDictionaryAddRemoveSameKey(stringArr1, intArr1, 50, 4); StringDriver.NonGenericIDictionaryAddRemoveSameKey(stringArr1, intArr1, 1, 5); StringDriver.NonGenericIDictionaryAddRemoveSameKey(stringArr1, intArr1, 98, 6); StringDriver.NonGenericIDictionaryRemoveValidations(stringArr1, intArr1); StringDriver.NonGenericIDictionaryRemoveValidations(new ValX1 <string>[] { }, new RefX1 <int>[] { }); Assert.True(test.result); }
public static int Main() { int i = 0; int[] int_arr = new int[] { 0, 1, 2, 3 }; int[] int_arr_res; new ArrayTest <int>().DoArrayTest(int_arr, out int_arr_res); for (i = 0; (i < 4); i++) { Eval(int_arr[i].Equals(int_arr_res[i])); } double[] double_arr = new double[] { 0, 1, 2, 3 }; double[] double_arr_res; new ArrayTest <double>().DoArrayTest(double_arr, out double_arr_res); for (i = 0; (i < 4); i++) { Eval(double_arr[i].Equals(double_arr_res[i])); } string[] string_arr = new string[] { "0", "1", "2", "3" }; string[] string_arr_res; new ArrayTest <string>().DoArrayTest(string_arr, out string_arr_res); for (i = 0; (i < 4); i++) { Eval(string_arr[i].Equals(string_arr_res[i])); } object[] object_arr = new object[] { "0", "1", "2", "3" }; object[] object_arr_res; new ArrayTest <object>().DoArrayTest(object_arr, out object_arr_res); for (i = 0; (i < 4); i++) { Eval(object_arr[i].Equals(object_arr_res[i])); } RefX1 <int>[] RefX1Int_arr = new RefX1 <int>[] { new RefX1 <int>(0), new RefX1 <int>(1), new RefX1 <int>(2), new RefX1 <int>(3) }; RefX1 <int>[] RefX1Int_arr_res; new ArrayTest <RefX1 <int> >().DoArrayTest(RefX1Int_arr, out RefX1Int_arr_res); for (i = 0; (i < 4); i++) { Eval(RefX1Int_arr[i].Equals(RefX1Int_arr_res[i])); } ValX1 <int>[] ValX1Int_arr = new ValX1 <int>[] { new ValX1 <int>(0), new ValX1 <int>(1), new ValX1 <int>(2), new ValX1 <int>(3) }; ValX1 <int>[] ValX1Int_arr_res; new ArrayTest <ValX1 <int> >().DoArrayTest(ValX1Int_arr, out ValX1Int_arr_res); for (i = 0; (i < 4); i++) { Eval(ValX1Int_arr[i].Equals(ValX1Int_arr_res[i])); } RefX1 <string>[] RefX1_arr = new RefX1 <string>[] { new RefX1 <string>("0"), new RefX1 <string>("1"), new RefX1 <string>("2"), new RefX1 <string>("3") }; RefX1 <string>[] RefX1_arr_res; new ArrayTest <RefX1 <string> >().DoArrayTest(RefX1_arr, out RefX1_arr_res); for (i = 0; (i < 4); i++) { Eval(RefX1_arr[i].Equals(RefX1_arr_res[i])); } ValX1 <string>[] ValX1_arr = new ValX1 <string>[] { new ValX1 <string>("0"), new ValX1 <string>("1"), new ValX1 <string>("2"), new ValX1 <string>("3") }; ValX1 <string>[] ValX1_arr_res; new ArrayTest <ValX1 <string> >().DoArrayTest(ValX1_arr, out ValX1_arr_res); for (i = 0; (i < 4); i++) { Eval(ValX1_arr[i].Equals(ValX1_arr_res[i])); } if (result) { Console.WriteLine("Test Passed"); return(100); } else { Console.WriteLine("Test Failed"); return(1); } }