public void TestToggleSetList() { int numSquares = 0, cnt; var numListPtr = new int[1]; int[] testList = { 1, 2, 3 }; var toggleObj = new ToggleItem(); toggleObj.SetList(0, ref numListPtr); toggleObj.GetList(ref numSquares, ref numListPtr); Assert.AreEqual(0, numSquares); toggleObj.SetList(3, ref testList); toggleObj.GetList(ref numSquares, ref numListPtr); Assert.AreEqual(3, numSquares); for (cnt = 0; cnt < 3; cnt++) { Assert.AreEqual(numListPtr[cnt], testList[cnt]); } }
public void TestToggle() { var toggleObj = new ToggleItem(); var numSquares = 0; var numListPtr = new int[1]; Assert.AreEqual(-1, toggleObj.GetNumSquares()); toggleObj.SetNumSquares(3); Assert.AreEqual(3, toggleObj.GetNumSquares()); toggleObj = new ToggleItem(); toggleObj.GetList(ref numSquares, ref numListPtr); Assert.AreEqual(-1, numSquares); }
private static void RunToggleTest(int P_idx) { var expectedTogglePattern = new int[Grid.MaxSquares]; int cnt, toggleTotalCnt = 0; var afterToggledPattern = new int[Grid.MaxSquares]; var toggleItemPtr = new int[1]; var gridObj = new Grid(); gridObj.InitGrid(); gridObj.RandomizeStartingGrid(); Square[] currGridPtr = gridObj.GetGrid(); for (cnt = 0; cnt < Grid.MaxSquares; cnt++) { expectedTogglePattern[cnt] = currGridPtr[cnt].GetState(); } // // We will toggle the changed suqares so that the // comparision will be easy. // ToggleItem toggleListPtr = gridObj.GetToggleList(P_idx); toggleListPtr.GetList(ref toggleTotalCnt, ref toggleItemPtr); for (cnt = 0; cnt < toggleTotalCnt; cnt++) { int currIdx = toggleItemPtr[cnt]; expectedTogglePattern[currIdx] ^= 1; } gridObj.ToggleGrid(P_idx); currGridPtr = gridObj.GetGrid(); for (cnt = 0; cnt < Grid.MaxSquares; cnt++) { afterToggledPattern[cnt] = currGridPtr[cnt].GetState(); } for (cnt = 0; cnt < Grid.MaxSquares; cnt++) { Assert.AreEqual(afterToggledPattern[cnt], expectedTogglePattern[cnt]); } }