public void BaseTest() { ArrayPrinter arrayPrinter = new ArrayPrinter(); this.arrayGenerator.RandomGenerator(this.Length); this.testArray = this.arrayGenerator.output; arrayPrinter.Print(this.testArray); this.mergeSort.Sort(this.testArray); arrayPrinter.Print(this.testArray); for (int i = 0; i < this.Length - 1; i++) { Assert.LessOrEqual(this.testArray[i], this.testArray[i + 1]); } }
static void Main(string[] args) { int value = 997; string[,] arrValues = new string[5, 5]; for (int i = 0; i < arrValues.GetLength(0); i++) { for (int j = 0; j < arrValues.GetLength(1); j++) { value++; arrValues[i, j] = value.ToString(); } } ArrayPrinter.PrintToConsole(arrValues); Console.ReadLine(); }
public void GenerateWorldLayer() { // Use the Assert class to test conditions. int x = 50; int z = 40; UnityEngine.Debug.Log("World Size: " + World.X + ", " + World.Z); Stopwatch sw = Stopwatch.StartNew(); sw.Start(); double[,] layer = World.getWorld().generateWorldLayer(-20.0, 40.0, 2.0, 2.5, true); sw.Stop(); UnityEngine.Debug.Log("Layer generation of size " + World.X + ", " + World.Z + " took " + sw.Elapsed + " secs."); verifyLayer(layer); ArrayPrinter.print(layer, "Test Layer: "); }
private void PrintGame() { string[,] mdArr = new string[4, 4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { mdArr[i, j] = string.Empty; } } int rowLength = mdArr.GetLength(0); int colLength = mdArr.GetLength(1); foreach (Tile item in currentGameState) { mdArr[item.Row, item.Column] = item.Number.ToString(); } ArrayPrinter.PrintToConsole(mdArr); }
public void ElevationMapTest() { // Use the Assert class to test conditions. int x = 40; int z = 40; World testWorld = World.generateNewWorld(x, z, false); Tile[,] worldArray = World.getWorld().getWorldArray(); double[,] array = new double[x, z]; for (int i = 0; i < x; i++) { for (int j = 0; j < z; j++) { array[i, j] = worldArray[i, j].getElevation(); assertBetween(array[i, j], -100.0, 100.0); assertHasBeenRoundedToXDecimals(array[i, j], 2); } } ArrayPrinter.print(array, "Elevation Map:"); }
public void MidpointTest() { // Use the Assert class to test conditions. int x = 40; int z = 40; World testWorld = World.generateNewWorld(x, z, false); Tile[,] worldArray = World.getWorld().getWorldArray(); double[,] array = new double[x, z]; for (int i = 0; i < x; i++) { for (int j = 0; j < z; j++) { array[i, j] = worldArray[i, j].getMidpoint(); assertBetween(array[i, j], 45.0, 75.0); assertHasBeenRoundedToXDecimals(array[i, j], 1); } } ArrayPrinter.print(array, "Midpoint Map:"); // VerifyWorld(); }
public void LowTempTest() { // Use the Assert class to test conditions. int x = 40; int z = 40; World testWorld = World.generateNewWorld(x, z, false); Tile[,] worldArray = World.getWorld().getWorldArray(); int[,] array = new int[x, z]; for (int i = 0; i < x; i++) { for (int j = 0; j < z; j++) { array[i, j] = worldArray[i, j].getLowTemp(); assertBetween(array[i, j], -20, 70); Assert.LessOrEqual(array[i, j].ToString().Length, 3); } } ArrayPrinter.print(array, "Low Temp Map:"); // VerifyWorld(); }
private static void ThreeWayOrdering(int[] input) { int low = 10; int mid = 30; int high = 31; int i = 0, j = 0; int k = input.Length - 1; while (j <= k) { if (input[j] < mid) { //swap var temp = input[i]; input[i] = input[j]; input[j] = temp; i++; j++; } else if (input[j] > mid) { //swap var temp = input[j]; input[j] = input[k]; input[k] = temp; k = k - 1; } else { j++; } } ArrayPrinter.Print(input); }
public void RunTests(string[] tests) { Utils.DebugMessage("************* CONFIGURATION ***************"); Utils.DebugMessage("TEST PLATFORM: " + Config.platform.ToString()); Utils.DebugMessage(""); Utils.DebugMessage("VERBOSE: " + Config.Verbose.ToString()); Utils.DebugMessage("OUTPUT UNLIMITED: " + Config.Unlimited.ToString()); Utils.DebugMessage("FAST MODE: " + Config.fast.ToString()); Utils.DebugMessage("OVERWRITE TARGET CODE: " + Config.overwriteTarget.ToString()); Utils.DebugMessage("PERFORMANCE TESTS: " + Config.performanceTests.ToString()); Utils.DebugMessage("COMPILATION MODE: " + Config.compileMode.ToString()); Utils.DebugMessage("*******************************************"); Console.WriteLine(); Console.WriteLine(); foreach (string _s in tests) { //Removed final '/' if exists string s = _s.TrimEnd('/'); Environment.CurrentDirectory = Utils.testPath; KeyValuePair <DirectoryInfo, TestResult> kvp = Tests.First(x => x.Key.Name == s); DirectoryInfo di = kvp.Key; TestResult res = kvp.Value; if (s.StartsWith("PT") && !Config.performanceTests) { res.cmakeCode = -10; res.alternative = -10; res.diffCode = -10; res.msbuildCode = -10; res.output = -10; continue; } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Running test " + di.Name); Console.ResetColor(); try { Environment.CurrentDirectory = Utils.alternativeDirectory; //Run alternative test.Alternative(di, res); Environment.CurrentDirectory = Utils.testPath; } catch (Exception e) { Console.WriteLine("ERROR IN ALTERNATIVE: " + e.Message); res.alternative = 1; } try { //Diff files Utils.diff(di, res); } catch (Exception e) { Console.WriteLine("ERROR IN DIFF: " + e.Message); res.diffCode = 1; } if (Config.fast) { res.output = res.msbuildCode = res.cmakeCode = -10; continue; } if (res.alternative == 0) { try { test.Make(di, res); } catch (Exception e) { Console.WriteLine("ERROR IN MAKE: " + e.Message); res.cmakeCode = -2; res.cmakeCode = -2; } } else { res.output = res.msbuildCode = res.cmakeCode = -10; } if (kvp.Value.msbuildCode == 0) { try { test.CompareOutputs(di, res); } catch (Exception e) { Console.WriteLine("ERROR COMPARING OUTPUTS: " + e.Message); res.output = 1; } } else { res.output = -10; } try { if (res.msbuildCode == 0 && Config.overwriteTarget) { Utils.OverwriteTarget(di); } //if (res.alternative == 0) // Utils.CountLines(di, res); } catch (Exception e) { Console.WriteLine("ERROR OVERWRITING FILES OR COUNTING LINES: " + e.Message); } } string[,] arr = new string[tests.Length + 1, 7]; arr[0, 0] = "NAME"; arr[0, 1] = "X-LATE"; arr[0, 2] = "DIFF"; arr[0, 3] = "CMAKE"; arr[0, 4] = "COMPILE"; // (" + Config.platform.ToString() + "|" + Config.compileMode.ToString() + ")"; arr[0, 5] = "OUTPUT"; arr[0, 6] = "TIME"; int i = 1; foreach (string _s in tests) { string s = _s.TrimEnd('/'); KeyValuePair <DirectoryInfo, TestResult> kvp = Tests.First(x => x.Key.Name == s); //KeyValuePair<DirectoryInfo, TestResult> kvp = SearchFirstWithName(s); arr[i, 0] = kvp.Value.name; arr[i, 1] = kvp.Value.alternative == 0 ? "#gSUCCESS" : (kvp.Value.alternative == -10 ? "#ySKIPPED" : "#rFAIL. Code: " + kvp.Value.alternative); arr[i, 2] = kvp.Value.diffCode == 0 ? "#gNo Differ" : (kvp.Value.diffCode == 1 ? "#rDiffer" : (kvp.Value.diffCode == -10 ? "#ySKIPPED" : "#rError. Code: " + kvp.Value.diffCode)); arr[i, 3] = kvp.Value.cmakeCode == 0 ? "#gSUCCESS" : (kvp.Value.cmakeCode == -10 ? "#ySKIPPED" : "#rFAIL. Code: " + kvp.Value.cmakeCode); arr[i, 4] = kvp.Value.msbuildCode == 0 ? "#gSUCCEESS" : (kvp.Value.msbuildCode == -10 ? "#ySKIPPED" : "#rFAIL. Code: " + kvp.Value.msbuildCode); arr[i, 5] = kvp.Value.output == 0 ? "#gOK" : (kvp.Value.output == -10 ? "#ySKIPPED" : "#rFAIL"); arr[i, 6] = (kvp.Value.msTimeSpan >= 0 ? (kvp.Value.msTimeSpan == 0 ? "#y" : "#r") : "#g") + kvp.Value.msTimeSpan.ToString() + " ms " + "(" + kvp.Value.relativeTime.ToString("N2") + "%)"; i++; } ArrayPrinter.PrintToConsole(arr); }