static void PrintDepartmentQuery(DepartmentsQuery dq) { Console.WriteLine("DepartmentQuery:"); if (!dq.IsVisited) { Console.WriteLine("Not visited\n"); } else { Console.WriteLine($"IsInf: {dq.IsInf}\nElems: "); foreach (var el in dq.Stamps) { foreach (var stamp in el) { Console.Write(stamp.ToString() + " "); } if (el.Length == 0) { Console.WriteLine("Length = 0"); } Console.WriteLine(); } Console.WriteLine(); } }
private static void Test11Helper(uint start, uint stop, bool[] isInfExpected, bool[] isVisited, uint[][][] stampsExpected, Departments dps) { for (uint i = start; i < stop; ++i) { DepartmentsQuery expected = new DepartmentsQuery(isInfExpected[i], isVisited[i], stampsExpected[i]); if (!expected.EqualTo(dps.Query(i + 1))) { isTest11Correct = false; } } }
private static bool MyTestHelper(bool[] isInfExpected, bool[] isVisited, uint[][][] stampsExpected, Departments dps, uint n) { bool tmp = true; for (uint i = 0; i < n; ++i) { DepartmentsQuery expected = new DepartmentsQuery(isInfExpected[i], isVisited[i], stampsExpected[i]); tmp = tmp && expected.EqualTo(dps.Query(i + 1)); if (tmp == false) { break; } } return(tmp); }
/// <summary> /// Determines whether the current DepartmentsQuery object /// and the other DepartmentsQuery object are equal. /// </summary> /// <param name="other"></param> /// <returns></returns> public bool EqualTo(DepartmentsQuery other) { if (!other.IsVisited && !IsVisited) { return(true); } if (other == null || other.IsInf != IsInf) { return(false); } if (other.Stamps.Length != Stamps.Length) { return(false); } for (int i = 0; i < Stamps.Length; ++i) { if (Stamps[i] == other.Stamps[i]) { if (Stamps[i] == null) { continue; } } if (Stamps[i] == null || other.Stamps[i] == null) { return(false); } if (Stamps[i].Length != Stamps[i].Length) { return(false); } uint[] ar1 = new uint[Stamps[i].Length]; uint[] ar2 = new uint[Stamps[i].Length]; Stamps[i].CopyTo(ar1, 0); other.Stamps[i].CopyTo(ar2, 0); for (int j = 0; j < Stamps[i].Length; ++j) { if (ar1[j] != ar2[j]) { return(false); } } } return(true); }