public static List<Struct.DoubleIndex> Dfs(char [,] map, Struct.DoubleIndex current, Struct.DoubleIndex target, char wall, bool isNew = true) { if (isNew) { currentPath.Clear (); bestPath = null; } currentPath.Insert (0, current.Clone()); if (current.Equals (target) && (bestPath == null || bestPath.Count > currentPath.Count)) bestPath = new List<Struct.DoubleIndex> (currentPath); if (bestPath != null && bestPath.Count <= currentPath.Count) return bestPath; for (int i = 0; i < directionsX.Length; i++) { current.first += directionsY[i]; current.second += directionsX[i]; if(!currentPath.Contains(current) && CanMove(map, current, wall)) Dfs (map, current, target, wall, false); current.first -= directionsY[i]; current.second -= directionsX[i]; } currentPath.RemoveAt (0); return bestPath; }
static void Main(string[] args) { TestEnv.TestEnv te= new TestEnv.TestEnv(); te.CheckComplainAndAdjustExpected( 0); Struct s = new Struct(); dlgt_vv aDlgt0 = s.foo; dlgt_vv aDlgt = s.foo; te.Test( 0== ( (Struct)aDlgt.Target).i); Struct sCopy1= (Struct) aDlgt.Target; te.Test( s.Equals( sCopy1)); // bb86f83d6448458db598c5fa849441c8 te.Test( aDlgt.Target.Equals( ( (dlgt_vv) s.foo).Target)); // 6494647464964967a30d5f91c399c818 te.Test( ! aDlgt.Equals( ( (dlgt_vv) s.foo))); te.Test( ! aDlgt0.Equals( aDlgt)); aDlgt(); //s.foo(); // not the same Result Struct sCopy2= (Struct) aDlgt.Target; // 109ea2c9d5584c15854be335d0b81884 te.Test( ! s.Equals( sCopy2)); // bb86f83d6448458db598c5fa849441c8 te.Test( ! aDlgt.Target.Equals( ( (dlgt_vv) s.foo).Target)); // 6494647464964967a30d5f91c399c818 te.Test( 0 == s.i); te.Test( 0 == sCopy1.i); te.Test( 1 == sCopy2.i); // 109ea2c9d5584c15854be335d0b81884 te.CheckComplainAndAdjustExpected( 10); System.Console.WriteLine( te.Result()); }
public void Equals() { Struct s1 = new Struct { 1, new Struct { 2 } }; Struct s2 = new Struct { 1, new Struct { 2 } }; Assert.IsTrue(s1.Equals(s2)); Struct s3 = new Struct { 1, new Struct { 3 } }; Assert.IsFalse(s1.Equals(s3)); Assert.IsTrue(@struct.Equals(@struct.Clone())); }
#pragma warning disable xUnit1024 // Test methods cannot have overloads public void Equals() #pragma warning restore xUnit1024 // Test methods cannot have overloads { Struct s1 = new Struct { 1, new Struct { 2 } }; Struct s2 = new Struct { 1, new Struct { 2 } }; Assert.IsTrue(s1.Equals(s2)); Struct s3 = new Struct { 1, new Struct { 3 } }; Assert.IsFalse(s1.Equals(s3)); Assert.IsTrue(@struct.Equals(@struct.Clone())); }
public void Equals() { Struct s1 = new() { 1, new Struct { 2 } }; Struct s2 = new() { 1, new Struct { 2 } }; Assert.IsTrue(s1.Equals(s2, ExecutionEngineLimits.Default)); Struct s3 = new() { 1, new Struct { 3 } }; Assert.IsFalse(s1.Equals(s3, ExecutionEngineLimits.Default)); Assert.ThrowsException <InvalidOperationException>(() => @struct.Equals(@struct.Clone(ExecutionEngineLimits.Default), ExecutionEngineLimits.Default)); } [TestMethod]
private bool Equals(CrossFrameworkClass other) { return(Sbyte == other.Sbyte && Short == other.Short && Int == other.Int && Long == other.Long && Byte == other.Byte && UShort == other.UShort && UInt == other.UInt && ULong == other.ULong && Char == other.Char && Math.Abs(Float - other.Float) < float.Epsilon && Math.Abs(Double - other.Double) < double.Epsilon && Decimal == other.Decimal && Boolean == other.Boolean && string.Equals(String, other.String) && DateTime.Equals(other.DateTime) // && Equals(Exception, other.Exception) && Exception.Message == other.Exception.Message && Enum == other.Enum && Struct.Equals(other.Struct)); }