Пример #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = IsActive.GetHashCode();
         hashCode = (hashCode * 397) ^ WireRed.GetHashCode();
         hashCode = (hashCode * 397) ^ WireGreen.GetHashCode();
         hashCode = (hashCode * 397) ^ WireBlue.GetHashCode();
         hashCode = (hashCode * 397) ^ WireYellow.GetHashCode();
         hashCode = (hashCode * 397) ^ LiquidType.GetHashCode();
         hashCode = (hashCode * 397) ^ TileColor.GetHashCode();
         hashCode = (hashCode * 397) ^ Wall.GetHashCode();
         hashCode = (hashCode * 397) ^ Type.GetHashCode();
         hashCode = (hashCode * 397) ^ WallColor.GetHashCode();
         hashCode = (hashCode * 397) ^ LiquidAmount.GetHashCode();
         hashCode = (hashCode * 397) ^ BrickStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ Actuator.GetHashCode();
         hashCode = (hashCode * 397) ^ BrickStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ InActive.GetHashCode();
         hashCode = (hashCode * 397) ^ U.GetHashCode();
         hashCode = (hashCode * 397) ^ V.GetHashCode();
         return(hashCode);
     }
 }
Пример #2
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Check the return hash code");

        try
        {
            Int16 i1   = TestLibrary.Generator.GetInt16(-55);
            int   hash = i1.GetHashCode();
            if (i1 == hash)
            {
                TestLibrary.TestFramework.LogError("001", "int16.gethashcode is equal to the int16 itself : " + i1);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Пример #3
0
 public override int GetHashCode()
 {
     return(val.GetHashCode());
 }
Пример #4
0
    public Boolean runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";

        try {
            do
            {
                ObjectManager      objMan;
                String             str1, str2;
                ISurrogateSelector isur = null;
                StreamingContext   sc1  = new StreamingContext(StreamingContextStates.All);
                strLoc = "Loc_100aa";
                objMan = new ObjectManager(isur, sc1);
                iCountTestcases++;
                try
                {
                    objMan.RegisterObject(null, 0);
                    iCountErrors++;
                    printerr("Error_100bb! Expected exception not thrown");
                }
                catch (ArgumentNullException) {
                }catch (Exception exc) {
                    iCountErrors++;
                    printerr("Error_100cc! Incorrect Exception thrown: exc==" + exc.ToString());
                }
                strLoc = "Loc_200aa";
                str1   = "Test";
                objMan = new ObjectManager(isur, sc1);
                objMan.RegisterObject(str1, 1);
                iCountTestcases++;
                if (!((String)objMan.GetObject(1)).Equals(str1))
                {
                    iCountErrors++;
                    printerr("Error_200bb! Incorrect object returned");
                }
                strLoc = "Loc_300aa";
                str1   = "Test";
                objMan = new ObjectManager(isur, sc1);
                iCountTestcases++;
                try
                {
                    objMan.RegisterObject(str1, -5);
                    iCountErrors++;
                    printerr("Error_300bb! Exception exception not thrown for negative Id");
                }
                catch (ArgumentException) {
                }catch (Exception exc) {
                    iCountErrors++;
                    printerr("Error_300cc! Incorrect exception thrown : exc==" + exc.ToString());
                }
                strLoc = "Loc_400aa";
                str1   = "Test";
                objMan = new ObjectManager(isur, sc1);
                objMan.RegisterObject(str1, Int64.MaxValue);
                iCountTestcases++;
                if (!((String)objMan.GetObject(Int64.MaxValue)).Equals(str1))
                {
                    iCountErrors++;
                    printerr("Error_856bdf! Incorrect object returned");
                }
                strLoc = "Loc_500aa";
                str1   = "Test1";
                str2   = "Test2";
                objMan = new ObjectManager(isur, sc1);
                objMan.RegisterObject(str1, 5);
                try
                {
                    objMan.RegisterObject(str2, 5);
                    iCountErrors++;
                    printerr("Error_493fh! Trying to register same ObjectID twice should throw exception");
                }
                catch (SerializationException)
                {
                }
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Loc8235vdr! Incorrect Exception thrown: \n" + exc.ToString());
                }
                iCountTestcases++;
                if (!((String)objMan.GetObject(5)).Equals(str1))
                {
                    iCountErrors++;
                    printerr("Error_500bb! Incorrect object returned");
                }
                Int16 i16SameValue = 20;
                Int32 i32SameValue = 1310740;
                objMan = new ObjectManager(isur, sc1);
                objMan.RegisterObject(i16SameValue, i16SameValue.GetHashCode());
                iCountTestcases++;
                try
                {
                    objMan.RegisterObject(i32SameValue, i32SameValue.GetHashCode());
                }
                catch (SerializationException) {}
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Loc 634623vvdrfe! Incorrect Exception thrown: \n" + exc.ToString());
                }
                strLoc = "Loc_600aa";
                objMan = new ObjectManager(isur, sc1);
                objMan.RegisterObject("Test1", 1);
                objMan.RegisterObject("Test2", 2);
                objMan.RegisterObject("Test3", 3);
                objMan.RegisterObject("Test4", 4);
                iCountTestcases++;
                if (!((String)objMan.GetObject(1)).Equals("Test1"))
                {
                    iCountErrors++;
                    printerr("Error_600bb! Incorrect object returned");
                }
                iCountTestcases++;
                if (!((String)objMan.GetObject(2)).Equals("Test2"))
                {
                    iCountErrors++;
                    printerr("Error_600cc! Incorrect object returned");
                }
                iCountTestcases++;
                if (!((String)objMan.GetObject(3)).Equals("Test3"))
                {
                    iCountErrors++;
                    printerr("Error_600dd! Incorrect object returned");
                }
                iCountTestcases++;
                if (!((String)objMan.GetObject(4)).Equals("Test4"))
                {
                    iCountErrors++;
                    printerr("Error_600ee! Incorrect object returned");
                }
                strLoc = "Loc_700aa";
                Object  var2 = 5;
                Decimal dec2 = (Decimal)10.5;
                Int16   i16  = 10;
                Int32   i32  = 10;
                Int64   i64  = 10;
                Single  sgl2 = (Single)5.5;
                Double  dbl2 = 5.5;
                objMan = new ObjectManager(isur, sc1);
                objMan.RegisterObject(var2, 1);
                objMan.RegisterObject(dec2, 2);
                objMan.RegisterObject(i16, 3);
                objMan.RegisterObject(i32, 4);
                objMan.RegisterObject(i64, 5);
                objMan.RegisterObject(sgl2, 6);
                objMan.RegisterObject(dbl2, 7);
                iCountTestcases++;
                if ((int)objMan.GetObject(1) != 5)
                {
                    iCountErrors++;
                    printerr("Error_700bb! Incorrect value returned");
                }
                iCountTestcases++;
                if ((Decimal)objMan.GetObject(2) != (Decimal)10.5)
                {
                    iCountErrors++;
                    printerr("Error_700cc! Incorrect Decimal value returned");
                }
                iCountTestcases++;
                if ((Int16)objMan.GetObject(3) != 10)
                {
                    iCountErrors++;
                    printerr("Error_700dd! Incorrect Int16 value returned");
                }
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.StackTrace);
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Пример #5
0
 public override int GetHashCode() => value.GetHashCode();
Пример #6
0
    public bool runTest()
    {
        Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";

        short[]   in2Arr = new Int16[10];
        int[]     in4Arr = new Int32[5];
        Boolean[] boArr = new Boolean[3];
        int       iHashCode1, iHashCode2;

        try {
            do
            {
                strLoc = "Loc_01hc";
                iCountTestcases++;
                in2Arr     = new Int16[10];
                iHashCode1 = in2Arr.GetHashCode();
                iHashCode2 = in2Arr.GetHashCode();
                if (iHashCode1 != iHashCode2)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + ", Err_01hc! , Array.GetHashCode on a same instance twice result different value.");
                }
                strLoc = "Loc_02hc";
                iCountTestcases++;
                in4Arr     = new Int32[5];
                iHashCode1 = in2Arr.GetHashCode();
                iHashCode2 = in4Arr.GetHashCode();
                if (iHashCode1 == iHashCode2)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + ", Err_02hc! , Array.GetHashCode on a different array type instances result same value.");
                }
                boArr  = new Boolean[3];
                strLoc = "Loc_03hc";
                iCountTestcases++;
                iHashCode1 = in2Arr.GetHashCode();
                iHashCode2 = boArr.GetHashCode();
                if (iHashCode1 == iHashCode2)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + ", Err_03hc! , Array.GetHashCode on a different array type instances result same value.");
                }
                strLoc = "Loc_04hc";
                iCountTestcases++;
                Array Arr1 = Array.CreateInstance(typeof(double), 10);
                Array Arr2 = Array.CreateInstance(typeof(Single), 0);
                iHashCode1 = Arr1.GetHashCode();
                iHashCode2 = Arr2.GetHashCode();
                if (iHashCode1 == iHashCode2)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + ", Err_04hc! , Array.GetHashCode on a different array type instances result same value.");
                }
                int[][] i4Arr = new int[3][];
                i4Arr[0] = new int[] { 1, 2, 3 };
                i4Arr[1] = new int[] { 1, 2, 3, 4, 5, 6 };
                i4Arr[2] = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
                strLoc   = "Loc_05hc";
                iCountTestcases++;
                iHashCode1 = i4Arr.GetHashCode();
                iHashCode2 = i4Arr.GetHashCode();
                if (iHashCode1 != iHashCode2)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + ", Err_05hc! , Array.GetHashCode on a same instance of jagged array should result same value.");
                }
                strLoc = "Loc_06hc";
                iCountTestcases++;
                string[,,,,,] strArr = new string[6, 5, 4, 3, 2, 1];
                iHashCode2           = strArr.GetHashCode();
                if (iHashCode1 == iHashCode2)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + ", Err_06hc! , Array.GetHashCode on a different array type instances result same value.");
                }
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + ", Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general);
        }
        if (iCountErrors == 0)
        {
            Console.Error.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,inCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Пример #7
0
    public virtual bool runTest()
    {
        Console.Error.WriteLine("Co1622Cons_Eq_GV_GHC runTest started.");
        Console.Out.WriteLine("");
        Console.Out.WriteLine("Method_Covered: Integer2.Equals (Microsoft/Runtime/Object)");
        Console.Out.WriteLine("Method_Covered: Integer2.GetValue ()");
        Console.Out.WriteLine("Method_Covered: Integer2.GetHashCode ()");
        Console.Out.WriteLine("Method_Count==3 (Co1622Cons_Eq_GV_GHC)");
        Console.Out.WriteLine("");
        String        strLoc          = "Loc_000oo";
        StringBuilder sblMsg          = new StringBuilder(99);
        int           iCountErrors    = 0;
        int           iCountTestcases = 0;
        String        str0            = null;
        String        str2            = null;
        StringBuilder sbl5            = new StringBuilder(99);
        int           in4r            = -2;
        int           in4s            = -2;
        short         sh2z            = (short)-2;
        short         sh2y            = (short)-2;
        Int32         int4e           = (Int32)0;
        Int16         sho2a           = (Int16)0;
        Int16         sho2b           = (Int16)0;

        try
        {
LABEL_860_GENERAL:
            do
            {
                sh2z        = (short)3;   strLoc = "Loc_110th";
                sbl5.Length = 0;
                str0        = sbl5.Append(sh2z).ToString();
                sho2a       = (Int16)(sh2z);
                sho2b       = (Int16)(sh2z);
                in4r        = sho2a.GetHashCode();
                ++iCountTestcases;
                if (sh2z == 0)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_184pr!  sh2z==" + sh2z + " ,in4r==" + in4r);
                }
                sh2y = sho2a;
                ++iCountTestcases;
                if (sh2z != sh2y)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_125ci!  sh2y==" + sh2y);
                }
                str2 = sho2a.ToString();
                ++iCountTestcases;
                if (!str2.Equals(str0))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_144ye!  str2==" + str2);
                }
                ++iCountTestcases;
                if (!sho2a.Equals(sho2b))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_199nd!  sh2z==" + sh2z);
                }
                sh2z        = (short)-4;   strLoc = "Loc_120tr";
                sbl5.Length = 0;
                str0        = sbl5.Append(sh2z).ToString();
                sho2a       = (Int16)(sh2z);
                sho2b       = (Int16)(sh2z);
                in4r        = sho2a.GetHashCode();
                ++iCountTestcases;
                if (sh2z != -4)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_184zl!  -sh2z==" + -sh2z);
                }
                sh2y = sho2a;
                ++iCountTestcases;
                if (sh2z != sh2y)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_125wa!  sh2y==" + sh2y);
                }
                str2 = sho2a.ToString();
                ++iCountTestcases;
                if (!str2.Equals(str0))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_144dy!  str2==" + str2);
                }
                ++iCountTestcases;
                if (!sho2a.Equals(sho2b))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_199uc!  sh2z==" + sh2z);
                }
                sh2z        = Int16.MinValue;   strLoc = "Loc_220nv";
                sbl5.Length = 0;
                str0        = sbl5.Append(sh2z).ToString();
                sho2a       = (Int16)(sh2z);
                sho2b       = (Int16)(sh2z);
                in4r        = sho2a.GetHashCode();
                ++iCountTestcases;
                if (sh2z != -32768)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_284pr!  ( sh2z  )==" + (sh2z));
                }
                sh2y = sho2a;
                ++iCountTestcases;
                if (sh2z != sh2y)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_225ci!  sh2y==" + sh2y);
                }
                str2 = sho2a.ToString();
                ++iCountTestcases;
                if (!str2.Equals(str0))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_244ye!  str2==" + str2);
                }
                ++iCountTestcases;
                if (!sho2a.Equals(sho2b))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_299nd!  sh2z==" + sh2z);
                }
                sh2z        = Int16.MaxValue;   strLoc = "Loc_330xv";
                sbl5.Length = 0;
                str0        = sbl5.Append(sh2z).ToString();
                sho2a       = (Int16)(sh2z);
                sho2b       = (Int16)(sh2z);
                in4r        = sho2a.GetHashCode();
                ++iCountTestcases;
                if (sh2z == 0)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_384pr!  sh2y==" + sh2y);
                }
                sh2y = sho2a;
                ++iCountTestcases;
                if (sh2z != sh2y)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_325ci!  sh2y==" + sh2y);
                }
                str2 = sho2a.ToString();
                ++iCountTestcases;
                if (!str2.Equals(str0))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_344ye!  str2==" + str2);
                }
                ++iCountTestcases;
                if (!sho2a.Equals(sho2b))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_399nd!  sh2z==" + sh2z);
                }
                sh2z        = (short)-0;   strLoc = "Loc_440nz";
                sbl5.Length = -0;
                str0        = sbl5.Append(sh2z).ToString();
                sho2a       = (Int16)(sh2z);
                sho2b       = (Int16)(sh2z);
                in4r        = sho2a.GetHashCode();
                ++iCountTestcases;
                if (sh2z != in4r)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_484pr!  sh2y==" + sh2y);
                }
                sh2y = sho2a;
                ++iCountTestcases;
                if (sh2z != sh2y)
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_425ci!  sh2y==" + sh2y);
                }
                str2 = sho2a.ToString();
                ++iCountTestcases;
                if (!str2.Equals(str0))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_444ye!  str2==" + str2);
                }
                ++iCountTestcases;
                if (!sho2a.Equals(sho2b))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_499nd!  sh2z==" + sh2z);
                }
                ++iCountTestcases;
                if (!str2.Equals("0"))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_461vj!  str2==" + str2);
                }
                int4e = (Int32)(-0);
                ++iCountTestcases;
                if (sho2a.Equals(int4e))
                {
                    ++iCountErrors;
                    Console.Error.WriteLine("POINTTOBREAK: Error Err_462mj!  int4e.ToString()==" + int4e.ToString());
                }
            } while (false);
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.Error.WriteLine("POINTTOBREAK: Error Err_343un! (Co1622Cons_Eq_GV_GHC) exc_general==" + exc_general);
            Console.Error.WriteLine("EXTENDEDINFO: (Err_343un) strLoc==" + strLoc);
        }
        if (iCountErrors == 0)
        {
            Console.Error.WriteLine("paSs.   Integer2\\Co1622Cons_Eq_GV_GHC.cs   iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.WriteLine("FAiL!   Integer2\\Co1622Cons_Eq_GV_GHC.cs   iCountErrors==" + iCountErrors);
            return(false);
        }
    }
Пример #8
0
 public override int GetHashCode()
 {
     return(_value.GetHashCode());
 }
Пример #9
0
 public override int GetHashCode()
 {
     // ReSharper disable NonReadonlyMemberInGetHashCode
     return(CombineHashCodes(hasValue.GetHashCode(), value.GetHashCode()));
     // ReSharper restore NonReadonlyMemberInGetHashCode
 }