public void getTest() { int[] ints = new int[3] { 0, 1, 2 }; VirtualArray<int> testArray = new VirtualArray<int>(ints); Assert.AreEqual(0, testArray[0], string.Format("[VirtualArray][get] expected {0}, received {1}", 0, testArray[0])); Assert.AreEqual(1, testArray[1], string.Format("[VirtualArray][get] expected {0}, received {1}", 1, testArray[1])); Assert.AreEqual(2, testArray[2], string.Format("[VirtualArray][get] expected {0}, received {1}", 2, testArray[2])); testArray.moveStartBy(1); Assert.AreEqual(1, testArray[0], string.Format("[VirtualArray][get] expected {0}, received {1}", 1, testArray[0])); Assert.AreEqual(2, testArray[1], string.Format("[VirtualArray][get] expected {0}, received {1}", 2, testArray[1])); testArray.moveStartBy(1); Assert.AreEqual(2, testArray[0], string.Format("[VirtualArray][get] expected {0}, received {1}", 2, testArray[0])); }
public virtual bool consume(VirtualArray<string> vArgs, ParsedArgs pArgs) { if (!isConsumeable(vArgs)) { return false; } pArgs.add(name, getValue(vArgs)); if (argCountIsRemainderOfArgs) { vArgs.moveStart(vArgs.endIndexExclusive); } else { vArgs.moveStartBy(argCount + 1); } return true; }
public void toListTest() { int[] ints = new int[] { 0, 1, 2, 4 }; VirtualArray<int> testArray = new VirtualArray<int>(ints); testArray.moveStartBy(1); testArray.moveEndBy(-1); List<int> result = testArray.toList(); Assert.AreEqual(2, result.Count, "[VirtualArray][toArray] Expected the result of toArray to have length 2"); Assert.AreEqual(1, result[0], "[VirtualArray][toArray] Encountered unexpected value in result of toArray."); Assert.AreEqual(2, result[1], "[VirtualArray][toArray] Encountered unexpected value in result of toArray."); }
public void setTest() { int[] ints = new int[3] { 0, 1, 2 }; VirtualArray<int> testArray = new VirtualArray<int>(ints); testArray[0] = -77; testArray[1] = -88; testArray[2] = -99; Assert.AreEqual(-77, testArray[0], string.Format("[VirtualArray][set] expected {0}, received {1}", -77, testArray[0])); Assert.AreEqual(-88, testArray[1], string.Format("[VirtualArray][set] expected {0}, received {1}", -88, testArray[1])); Assert.AreEqual(-99, testArray[2], string.Format("[VirtualArray][set] expected {0}, received {1}", -99, testArray[2])); testArray.moveStartBy(1); testArray[0] += 88; Assert.AreEqual(0, testArray[0], string.Format("[VirtualArray][set] expected {0}, received {1}", 0, testArray[0])); }