Example #1
0
        public void Should_match_the_forth_case(
            MyStruct2 instance)
        {
            int result = Match(instance);

            Assert.Equal(4, result);
        }
Example #2
0
    public bool NegTest11()
    {
        bool      retVal = true;
        Array     array;
        int       length;
        MyStruct2 element;
        int       index;
        int       newIndex;

        TestLibrary.TestFramework.BeginScenario("NegTest11: Array.BinarySearch(Array, int, int, object, IComparer) non-primitive type (not derived from object or IComparable)");

        try
        {
            // creat the array
            length = (TestLibrary.Generator.GetInt32(-55) % (c_MAX_SIZE - c_MIN_SIZE)) + c_MIN_SIZE;
            array  = Array.CreateInstance(typeof(MyStruct2), length);

            element = new MyStruct2(TestLibrary.Generator.GetSingle(-55));

            // fill the array
            for (int i = 0; i < array.Length; i++)
            {
                do
                {
                    array.SetValue(new MyStruct2(TestLibrary.Generator.GetSingle(-55)), i);
                }while(element.f == ((MyStruct2)array.GetValue(i)).f);
            }

            // set the lucky index
            index = TestLibrary.Generator.GetInt32(-55) % length;

            // set the value
            array.SetValue(element, index);

            Array.Sort(array);

            newIndex = Array.BinarySearch(array, 0, array.Length, (object)element, null);

            TestLibrary.TestFramework.LogError("024", "Exception expected");
            retVal = false;
        }
        catch (InvalidOperationException)
        {
            // expected
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("025", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Example #3
0
 //si el heroe toca al el zombie o el ciudadano se ejecuta el mensaje correspondiente
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.GetComponent <Ciuadano>())
     {
         ciudadanoInfo    = collision.gameObject.GetComponent <Ciuadano>().info2();
         information      = collision.gameObject.GetComponent <Ciuadano>().infoAll();
         infoCitycen.text = ("Hola soy " + ciudadanoInfo.myName + " y tengo " + information.age);
         infoZombie.gameObject.SetActive(false);
         infoCitycen.gameObject.SetActive(true);
         exit.gameObject.SetActive(true);
     }
 }
 public Boolean runTest()
   {
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc="123_er";
   Console.Out.Write( s_strClassMethod );
   Console.Out.Write( ": " );
   Console.Out.Write( s_strTFPath + s_strTFName );
   Console.Out.Write( ": " );
   Console.Out.Write( s_strDtTmVer );
   Console.Out.WriteLine( " runTest started..." );
   ValueType vt1;
   MyStruct1 mystr1;
   MyStruct2 mystr2;
   Int64 lVal;
   try {
   mystr1 = new MyStruct1(5);								
   iCountTestcases++;
   if(!mystr1.ToString().Equals("MyStruct1")) {
   iCountErrors++;
   Console.WriteLine("Err_53vd! ValueType change detected, please take a look");
   }									
   vt1 = mystr1;
   iCountTestcases++;
   if(!vt1.ToString().Equals("MyStruct1")) {
   iCountErrors++;
   Console.WriteLine("Err_8536cd! ValueType change detected, please take a look");
   }			
   lVal = 50;
   mystr2 = new MyStruct2(lVal);
   iCountTestcases++;
   if(!mystr2.ToString().Equals("50")) {
   iCountErrors++;
   Console.WriteLine("Err_210cdp! ValueType change detected, please take a look, " + mystr2);
   }			
   vt1 = mystr2;
   iCountTestcases++;
   if(!vt1.ToString().Equals("50")) {
   iCountErrors++;
   Console.WriteLine("Err_93246cds! ValueType change detected, please take a look, " + vt1);
   }			
   }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 +"  ,iCountErrors=="+ iCountErrors +" ,BugNums?: "+ s_strActiveBugNums );
   return false;
   }
   }
Example #5
0
        static void Class3()
        {
            var ms = new MyStruct2();

            ms.s = "string";
            var mc = new MyClass2();

            mc.s = "string";
            ChangeStructString(ms);
            ChangeClassString(mc);
            Console.WriteLine($"Original string => string");
            Console.WriteLine($"Struct new string => {ms.s}");
            Console.WriteLine($"Class new string => {mc.s}");
        }
Example #6
0
    //si el heroe toca al el zombie o el ciudadano se ejecuta el mensaje correspondiente
    public void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.GetComponent <Zombie>())
        {
            zombieInfo = collision.gameObject.GetComponent <Zombie>().Info();
            //Se ejecuta el mensaje
            Debug.Log("awrrr quiero comer tu " + zombieInfo.myGusto2);
            healtBar.SendMessage("TakeDamage", 15);
        }

        if (collision.gameObject.GetComponent <Ciuadano>())
        {
            ciudadanoInfo = collision.gameObject.GetComponent <Ciuadano>().info2();
            //Se ejecuta el mensaje
            Debug.Log("Hola soy " + ciudadanoInfo.myName + " y tengo " + ciudadanoInfo.edad);
        }
    }
Example #7
0
    static int Main(string[] args)
    {
        int      returnVal = Pass;
        MyStruct s         = new MyStruct(1, 2, 3, 4);
        int      sum       = AddFields(s);

        if (sum != 10)
        {
            Console.WriteLine("Failed first call");
            returnVal = Fail;
        }
        s   = MyStruct.newMyStruct(1, 2, 3, 4);
        sum = AddFields(s);
        if (sum != 10)
        {
            Console.WriteLine("Failed second call");
            returnVal = Fail;
        }
        MyStruct2 s2 = new MyStruct2(1, 2, 3.0, 4);

        sum = AddFields2(s2);
        if (sum != 10)
        {
            Console.WriteLine("Failed third call");
            returnVal = Fail;
        }
        MyStruct3 s3 = new MyStruct3(1, 2, 3.0, 4);

        sum = AddFields3(s3);
        if (sum != 10)
        {
            Console.WriteLine("Failed fourth call");
            returnVal = Fail;
        }
        if (returnVal == Pass)
        {
            Console.WriteLine("Pass");
        }
        return(returnVal);
    }
 public Boolean runTest()
   {
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc="123_er";
   Console.Out.Write( s_strClassMethod );
   Console.Out.Write( ": " );
   Console.Out.Write( s_strTFPath + s_strTFName );
   Console.Out.Write( ": " );
   Console.Out.Write( s_strDtTmVer );
   Console.Out.WriteLine( " runTest started..." );
   ValueType vt1;
   MyStruct1 mystr1;
   MyStruct1 mystr11;
   MyStruct2 mystr2;
   MyStruct2 mystr22;
   MyStruct3 mystr3;
   MyStruct3 mystr33;
   MyStruct4 mystr4;
   MyStruct4 mystr44;
   MyStruct5 mystr5;
   MyStruct5 mystr55;
   MyStruct6 mystr6;
   MyStruct6 mystr66;
   MyStruct7 mystr7;
   MyStruct7 mystr77;
   Color enumCol1;
   Color enumCol2;
   object objValue1;
   object objValue2;
   try {
   mystr1 = new MyStruct1(5);								
   mystr11 = mystr1;
   iCountTestcases++;
   if(!mystr1.Equals(mystr11)) {
   iCountErrors++;
   Console.WriteLine("Err_53vd! ValueType change detected, please take a look");
   }									
   vt1 = mystr1;
   iCountTestcases++;
   if(!vt1.Equals(mystr1)) {
   iCountErrors++;
   Console.WriteLine("Err_8536cd! ValueType change detected, please take a look");
   }			
   objValue1 = mystr1;
   iCountTestcases++;
   if(!objValue1.Equals(mystr1)) {
   iCountErrors++;
   Console.WriteLine("Err_7563fdg! ValueType change detected, please take a look");
   }	
   mystr1 = new MyStruct1(5);
   mystr11 = new MyStruct1(5);
   iCountTestcases++;
   if(!mystr1.Equals(mystr11)) {
   iCountErrors++;
   Console.WriteLine("Err_175td! ValueType change detected, please take a look");
   }
   mystr1 = new MyStruct1(5);
   mystr2 = new MyStruct2(5);
   iCountTestcases++;
   if(mystr1.Equals(mystr2)) {
   iCountErrors++;
   Console.WriteLine("Err_62c8sb! ValueType change detected, please take a look");
   }												
   mystr2 = new MyStruct2(5);
   mystr22 = new MyStruct2(5);
   iCountTestcases++;
   if(!mystr2.Equals(mystr22)) {
   iCountErrors++;
   Console.WriteLine("Err_753cs! ValueType change detected, please take a look");
   }												
   mystr2 = new MyStruct2(5);
   mystr22 = new MyStruct2(5);
   vt1 = mystr22;
   iCountTestcases++;
   if(!mystr2.Equals(vt1)) {
   iCountErrors++;
   Console.WriteLine("Err_653cds! ValueType change detected, please take a look");
   }												
   mystr3 = new MyStruct3();
   mystr33 = new MyStruct3();
   iCountTestcases++;
   if(!mystr3.Equals(mystr33)) {
   iCountErrors++;
   Console.WriteLine("Err_105ds! ValueType change detected, please take a look");
   }												
   vt1 = mystr33;
   iCountTestcases++;
   if(!mystr3.Equals(vt1)) {
   iCountErrors++;
   Console.WriteLine("Err_01435xs! ValueType change detected, please take a look");
   }												
   mystr4 = new MyStruct4(5);
   mystr44 = new MyStruct4(15);
   iCountTestcases++;
   if(!mystr4.Equals(mystr44)) {
   iCountErrors++;
   Console.WriteLine("Err_642cd! ValueType change detected, please take a look");
   }												
   mystr44 = new MyStruct4(20);
   vt1 = mystr44;
   iCountTestcases++;
   if(!mystr4.Equals(vt1)) {
   iCountErrors++;
   Console.WriteLine("Err_5420csd! ValueType change detected, please take a look");
   }												
   mystr5 = new MyStruct5(5);
   mystr55 = new MyStruct5(5);
   iCountTestcases++;
   if(!mystr5.Equals(mystr55)) {
   iCountErrors++;
   Console.WriteLine("Err_519amg! ValueType change detected, please take a look");
   }												
   vt1 = mystr55;
   iCountTestcases++;
   if(!mystr5.Equals(vt1)) {
   iCountErrors++;
   Console.WriteLine("Err_17cdx ValueType change detected, please take a look");
   }												
   mystr5 = new MyStruct5(5);
   mystr55 = new MyStruct5(15);
   iCountTestcases++;
   if(mystr5.Equals(mystr55)) {
   iCountErrors++;
   Console.WriteLine("Err_105xcs! ValueType change detected, please take a look");
   }												
   mystr6 = new MyStruct6();
   mystr66 = new MyStruct6();
   iCountTestcases++;
   if(!mystr6.Equals(mystr66)) {
   iCountErrors++;
   Console.WriteLine("Err_0356cd! ValueType change detected, please take a look");
   }												
   vt1 = mystr66;
   iCountTestcases++;
   if(!mystr6.Equals(vt1)) {
   iCountErrors++;
   Console.WriteLine("Err_045ds! ValueType change detected, please take a look");
   }												
   mystr7 = new MyStruct7(5);
   mystr77 = new MyStruct7(5);
   iCountTestcases++;
   if(mystr7.Equals(mystr77)) {
   iCountErrors++;
   Console.WriteLine("Err_02345cd! ValueType change detected, please take a look");
   }												
   vt1 = mystr77;
   iCountTestcases++;
   if(mystr7.Equals(vt1)) {
   iCountErrors++;
   Console.WriteLine("Err_2106fcd ValueType change detected, please take a look");
   }												
   mystr7 = new MyStruct7(5);
   mystr77 = new MyStruct7(15);
   iCountTestcases++;
   if(mystr7.Equals(mystr77)) {
   iCountErrors++;
   Console.WriteLine("Err_0436cs! ValueType change detected, please take a look");
   }												
   enumCol1 = Color.Red;
   enumCol2 = Color.Red;
   iCountTestcases++;
   if(!enumCol1.Equals(enumCol2)) {
   iCountErrors++;
   Console.WriteLine("Err_0436cs! ValueType change detected, please take a look");
   }												
   objValue1 = enumCol1;
   objValue2 = enumCol2;
   iCountTestcases++;
   if(!objValue1.Equals(objValue2)) {
   iCountErrors++;
   Console.WriteLine("Err_0436cs! ValueType change detected, please take a look");
   }												
   }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 +"  ,iCountErrors=="+ iCountErrors +" ,BugNums?: "+ s_strActiveBugNums );
   return false;
   }
   }
Example #9
0
    public Boolean runTest()
    {
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "123_er";

        Console.Out.Write(s_strClassMethod);
        Console.Out.Write(": ");
        Console.Out.Write(s_strTFPath + s_strTFName);
        Console.Out.Write(": ");
        Console.Out.Write(s_strDtTmVer);
        Console.Out.WriteLine(" runTest started...");
        ValueType vt1;
        MyStruct1 mystr1;
        MyStruct1 mystr11;
        MyStruct2 mystr2;
        MyStruct2 mystr22;
        MyStruct3 mystr3;
        MyStruct3 mystr33;
        MyStruct4 mystr4;
        MyStruct4 mystr44;
        MyStruct5 mystr5;
        MyStruct5 mystr55;
        MyStruct6 mystr6;
        MyStruct6 mystr66;
        MyStruct7 mystr7;
        MyStruct7 mystr77;
        Color     enumCol1;
        Color     enumCol2;
        object    objValue1;
        object    objValue2;

        try {
            mystr1  = new MyStruct1(5);
            mystr11 = mystr1;
            iCountTestcases++;
            if (!mystr1.Equals(mystr11))
            {
                iCountErrors++;
                Console.WriteLine("Err_53vd! ValueType change detected, please take a look");
            }
            vt1 = mystr1;
            iCountTestcases++;
            if (!vt1.Equals(mystr1))
            {
                iCountErrors++;
                Console.WriteLine("Err_8536cd! ValueType change detected, please take a look");
            }
            objValue1 = mystr1;
            iCountTestcases++;
            if (!objValue1.Equals(mystr1))
            {
                iCountErrors++;
                Console.WriteLine("Err_7563fdg! ValueType change detected, please take a look");
            }
            mystr1  = new MyStruct1(5);
            mystr11 = new MyStruct1(5);
            iCountTestcases++;
            if (!mystr1.Equals(mystr11))
            {
                iCountErrors++;
                Console.WriteLine("Err_175td! ValueType change detected, please take a look");
            }
            mystr1 = new MyStruct1(5);
            mystr2 = new MyStruct2(5);
            iCountTestcases++;
            if (mystr1.Equals(mystr2))
            {
                iCountErrors++;
                Console.WriteLine("Err_62c8sb! ValueType change detected, please take a look");
            }
            mystr2  = new MyStruct2(5);
            mystr22 = new MyStruct2(5);
            iCountTestcases++;
            if (!mystr2.Equals(mystr22))
            {
                iCountErrors++;
                Console.WriteLine("Err_753cs! ValueType change detected, please take a look");
            }
            mystr2  = new MyStruct2(5);
            mystr22 = new MyStruct2(5);
            vt1     = mystr22;
            iCountTestcases++;
            if (!mystr2.Equals(vt1))
            {
                iCountErrors++;
                Console.WriteLine("Err_653cds! ValueType change detected, please take a look");
            }
            mystr3  = new MyStruct3();
            mystr33 = new MyStruct3();
            iCountTestcases++;
            if (!mystr3.Equals(mystr33))
            {
                iCountErrors++;
                Console.WriteLine("Err_105ds! ValueType change detected, please take a look");
            }
            vt1 = mystr33;
            iCountTestcases++;
            if (!mystr3.Equals(vt1))
            {
                iCountErrors++;
                Console.WriteLine("Err_01435xs! ValueType change detected, please take a look");
            }
            mystr4  = new MyStruct4(5);
            mystr44 = new MyStruct4(15);
            iCountTestcases++;
            if (!mystr4.Equals(mystr44))
            {
                iCountErrors++;
                Console.WriteLine("Err_642cd! ValueType change detected, please take a look");
            }
            mystr44 = new MyStruct4(20);
            vt1     = mystr44;
            iCountTestcases++;
            if (!mystr4.Equals(vt1))
            {
                iCountErrors++;
                Console.WriteLine("Err_5420csd! ValueType change detected, please take a look");
            }
            mystr5  = new MyStruct5(5);
            mystr55 = new MyStruct5(5);
            iCountTestcases++;
            if (!mystr5.Equals(mystr55))
            {
                iCountErrors++;
                Console.WriteLine("Err_519amg! ValueType change detected, please take a look");
            }
            vt1 = mystr55;
            iCountTestcases++;
            if (!mystr5.Equals(vt1))
            {
                iCountErrors++;
                Console.WriteLine("Err_17cdx ValueType change detected, please take a look");
            }
            mystr5  = new MyStruct5(5);
            mystr55 = new MyStruct5(15);
            iCountTestcases++;
            if (mystr5.Equals(mystr55))
            {
                iCountErrors++;
                Console.WriteLine("Err_105xcs! ValueType change detected, please take a look");
            }
            mystr6  = new MyStruct6();
            mystr66 = new MyStruct6();
            iCountTestcases++;
            if (!mystr6.Equals(mystr66))
            {
                iCountErrors++;
                Console.WriteLine("Err_0356cd! ValueType change detected, please take a look");
            }
            vt1 = mystr66;
            iCountTestcases++;
            if (!mystr6.Equals(vt1))
            {
                iCountErrors++;
                Console.WriteLine("Err_045ds! ValueType change detected, please take a look");
            }
            mystr7  = new MyStruct7(5);
            mystr77 = new MyStruct7(5);
            iCountTestcases++;
            if (mystr7.Equals(mystr77))
            {
                iCountErrors++;
                Console.WriteLine("Err_02345cd! ValueType change detected, please take a look");
            }
            vt1 = mystr77;
            iCountTestcases++;
            if (mystr7.Equals(vt1))
            {
                iCountErrors++;
                Console.WriteLine("Err_2106fcd ValueType change detected, please take a look");
            }
            mystr7  = new MyStruct7(5);
            mystr77 = new MyStruct7(15);
            iCountTestcases++;
            if (mystr7.Equals(mystr77))
            {
                iCountErrors++;
                Console.WriteLine("Err_0436cs! ValueType change detected, please take a look");
            }
            enumCol1 = Color.Red;
            enumCol2 = Color.Red;
            iCountTestcases++;
            if (!enumCol1.Equals(enumCol2))
            {
                iCountErrors++;
                Console.WriteLine("Err_0436cs! ValueType change detected, please take a look");
            }
            objValue1 = enumCol1;
            objValue2 = enumCol2;
            iCountTestcases++;
            if (!objValue1.Equals(objValue2))
            {
                iCountErrors++;
                Console.WriteLine("Err_0436cs! ValueType change detected, please take a look");
            }
        }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 + "  ,iCountErrors==" + iCountErrors + " ,BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
 public Boolean runTest()
   {
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc="123_er";
   Console.Out.Write( s_strClassMethod );
   Console.Out.Write( ": " );
   Console.Out.Write( s_strTFPath + s_strTFName );
   Console.Out.Write( ": " );
   Console.Out.Write( s_strDtTmVer );
   Console.Out.WriteLine( " runTest started..." );
   ValueType vt1;
   MyStruct1 mystr1;
   MyStruct2 mystr2;
   MyStruct3 mystr3;
   MyStruct4 mystr4;
   MyStruct5 mystr5;
   MyStruct6 mystr6;
   MyStruct7 mystr7;
   Int32 iValue;
   try {
   iValue = 5;
   mystr1 = new MyStruct1(5);											
   iCountTestcases++;
   if(mystr1.GetHashCode() == 0) {
   iCountErrors++;
   Console.WriteLine("Err_53vd! ValueType change detected, please take a look, " + mystr1.GetHashCode());
   }									
   vt1 = mystr1;
   iCountTestcases++;
   if(vt1.GetHashCode() != mystr1.GetHashCode()) {
   iCountErrors++;
   Console.WriteLine("Err_8536cd! ValueType change detected, please take a look, " + mystr1.GetHashCode());
   }			
   iValue = 5;
   mystr2 = new MyStruct2(5);			
   iCountTestcases++;
   if(mystr2.GetHashCode() != iValue*2) {
   iCountErrors++;
   Console.WriteLine("Err_539fvd! ValueType change detected, please take a look, " + mystr1.GetHashCode());
   }									
   vt1 = mystr2;
   iCountTestcases++;
   if(vt1.GetHashCode() != iValue*2) {
   iCountErrors++;
   Console.WriteLine("Err_0565cs! ValueType change detected, please take a look, " + mystr1.GetHashCode());
   }			
   mystr3 = new MyStruct3();
   iCountTestcases++;
   if(mystr3.GetHashCode() == 0) {
   iCountErrors++;
   Console.WriteLine("Err_6553cs! ValueType change detected, please take a look, " + mystr3.GetHashCode());
   }									
   vt1 = mystr3;
   iCountTestcases++;
   if(vt1.GetHashCode() != mystr3.GetHashCode()) {
   iCountErrors++;
   Console.WriteLine("Err_014xs! ValueType change detected, please take a look, " + vt1.GetHashCode());
   }			
   mystr4 = new MyStruct4(10);
   iCountTestcases++;
   if(mystr4.GetHashCode() == 0) {	
   iCountErrors++;
   Console.WriteLine("Err_5538cd! ValueType change detected, please take a look, " + mystr1.GetHashCode());
   }									
   vt1 = mystr4;
   iCountTestcases++;
   if(vt1.GetHashCode() != mystr4.GetHashCode()) {
   iCountErrors++;
   Console.WriteLine("Err_510apm! ValueType change detected, please take a look, " + mystr1.GetHashCode());
   }			
   mystr5 = new MyStruct5();
   iCountTestcases++;
   if(mystr5.GetHashCode() == 0) {	
   iCountErrors++;
   Console.WriteLine("Err_295msn! ValueType change detected, please take a look, " + mystr5.GetHashCode());
   }
   vt1 = mystr5;
   iCountTestcases++;
   if(vt1.GetHashCode() != mystr5.GetHashCode()) {
   iCountErrors++;
   Console.WriteLine("Err_0432emc! ValueType change detected, please take a look, " + vt1.GetHashCode());
   }	
   mystr5 = new MyStruct5(10);
   iCountTestcases++;
   if(mystr5.GetHashCode() == 0) {	
   iCountErrors++;
   Console.WriteLine("Err_54238ds! ValueType change detected, please take a look, " + mystr5.GetHashCode());
   }
   vt1 = mystr5;
   iCountTestcases++;
   if(vt1.GetHashCode() != mystr5.GetHashCode()) {
   iCountErrors++;
   Console.WriteLine("Err_6530vf! ValueType change detected, please take a look, " + vt1.GetHashCode());
   }	
   mystr6 = new MyStruct6();
   iCountTestcases++;
   if(mystr6.GetHashCode() == 0) {
   iCountErrors++;
   Console.WriteLine("Err_753fsd! ValueType change detected, please take a look, " + mystr5.GetHashCode());
   }
   vt1 = mystr6;
   iCountTestcases++;
   if(vt1.GetHashCode() != mystr6.GetHashCode()) {
   iCountErrors++;
   Console.WriteLine("Err_7634vcd! ValueType change detected, please take a look, " + vt1.GetHashCode());
   }	
   mystr7 = new MyStruct7(5);
   iCountTestcases++;
   if(mystr7.GetHashCode() == 0) {	
   iCountErrors++;
   Console.WriteLine("Err_653cd! ValueType change detected, please take a look, " + mystr7.GetHashCode() + " " + typeof(MyStruct7).GetHashCode());
   }
   vt1 = mystr7;
   iCountTestcases++;
   if(vt1.GetHashCode() != mystr7.GetHashCode()) {
   iCountErrors++;
   Console.WriteLine("Err_6537dsfc ValueType change detected, please take a look, " + vt1.GetHashCode());
   }	
   }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 +"  ,iCountErrors=="+ iCountErrors +" ,BugNums?: "+ s_strActiveBugNums );
   return false;
   }
   }
Example #11
0
 private static void ChangeStructString(MyStruct2 ms)
 {
     ms.s = "new string";
 }
Example #12
0
 public void Should_match_the_forth_case(
     MyStruct2 instance)
 {
     int result = Match(instance);
     Assert.Equal(4, result);
 }
Example #13
0
    public Boolean runTest()
    {
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "123_er";

        Console.Out.Write(s_strClassMethod);
        Console.Out.Write(": ");
        Console.Out.Write(s_strTFPath + s_strTFName);
        Console.Out.Write(": ");
        Console.Out.Write(s_strDtTmVer);
        Console.Out.WriteLine(" runTest started...");
        ValueType vt1;
        MyStruct1 mystr1;
        MyStruct2 mystr2;
        MyStruct3 mystr3;
        MyStruct4 mystr4;
        MyStruct5 mystr5;
        MyStruct6 mystr6;
        MyStruct7 mystr7;
        Int32     iValue;

        try {
            iValue = 5;
            mystr1 = new MyStruct1(5);
            iCountTestcases++;
            if (mystr1.GetHashCode() != iValue)
            {
                iCountErrors++;
                Console.WriteLine("Err_53vd! ValueType change detected, please take a look, " + mystr1.GetHashCode());
            }
            vt1 = mystr1;
            iCountTestcases++;
            if (vt1.GetHashCode() != iValue)
            {
                iCountErrors++;
                Console.WriteLine("Err_8536cd! ValueType change detected, please take a look, " + mystr1.GetHashCode());
            }
            iValue = 5;
            mystr2 = new MyStruct2(5);
            iCountTestcases++;
            if (mystr2.GetHashCode() != iValue * 2)
            {
                iCountErrors++;
                Console.WriteLine("Err_539fvd! ValueType change detected, please take a look, " + mystr1.GetHashCode());
            }
            vt1 = mystr2;
            iCountTestcases++;
            if (vt1.GetHashCode() != iValue * 2)
            {
                iCountErrors++;
                Console.WriteLine("Err_0565cs! ValueType change detected, please take a look, " + mystr1.GetHashCode());
            }
            mystr3 = new MyStruct3();
            iCountTestcases++;
            if (mystr3.GetHashCode() == 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_6553cs! ValueType change detected, please take a look, " + mystr3.GetHashCode());
            }
            vt1 = mystr3;
            iCountTestcases++;
            if (vt1.GetHashCode() != mystr3.GetHashCode())
            {
                iCountErrors++;
                Console.WriteLine("Err_014xs! ValueType change detected, please take a look, " + vt1.GetHashCode());
            }
            mystr4 = new MyStruct4(10);
            iCountTestcases++;
            if (mystr4.GetHashCode() == 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_5538cd! ValueType change detected, please take a look, " + mystr1.GetHashCode());
            }
            vt1 = mystr4;
            iCountTestcases++;
            if (vt1.GetHashCode() != mystr4.GetHashCode())
            {
                iCountErrors++;
                Console.WriteLine("Err_510apm! ValueType change detected, please take a look, " + mystr1.GetHashCode());
            }
            mystr5 = new MyStruct5();
            iCountTestcases++;
            if (mystr5.GetHashCode() != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_295msn! ValueType change detected, please take a look, " + mystr5.GetHashCode());
            }
            vt1 = mystr5;
            iCountTestcases++;
            if (vt1.GetHashCode() != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0432emc! ValueType change detected, please take a look, " + vt1.GetHashCode());
            }
            mystr5 = new MyStruct5(10);
            iCountTestcases++;
            if (mystr5.GetHashCode() != 10 + 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_54238ds! ValueType change detected, please take a look, " + mystr5.GetHashCode());
            }
            vt1 = mystr5;
            iCountTestcases++;
            if (vt1.GetHashCode() != 10 + 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_6530vf! ValueType change detected, please take a look, " + vt1.GetHashCode());
            }
            mystr6 = new MyStruct6();
            iCountTestcases++;
            if (mystr6.GetHashCode() == 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_753fsd! ValueType change detected, please take a look, " + mystr5.GetHashCode());
            }
            vt1 = mystr6;
            iCountTestcases++;
            if (vt1.GetHashCode() != mystr6.GetHashCode())
            {
                iCountErrors++;
                Console.WriteLine("Err_7634vcd! ValueType change detected, please take a look, " + vt1.GetHashCode());
            }
            mystr7 = new MyStruct7(5);
            iCountTestcases++;
            if (mystr7.GetHashCode() == 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_653cd! ValueType change detected, please take a look, " + mystr7.GetHashCode() + " " + typeof(MyStruct7).GetHashCode());
            }
            vt1 = mystr7;
            iCountTestcases++;
            if (vt1.GetHashCode() != mystr7.GetHashCode())
            {
                iCountErrors++;
                Console.WriteLine("Err_6537dsfc ValueType change detected, please take a look, " + vt1.GetHashCode());
            }
        }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 + "  ,iCountErrors==" + iCountErrors + " ,BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Example #14
0
 static int AddFields2(MyStruct2 s)
 {
     return((int)(s.f1 + s.f2 + (int)s.f3 + s.f4[0]));
 }
Example #15
0
    public Boolean runTest()
    {
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "123_er";

        Console.Out.Write(s_strClassMethod);
        Console.Out.Write(": ");
        Console.Out.Write(s_strTFPath + s_strTFName);
        Console.Out.Write(": ");
        Console.Out.Write(s_strDtTmVer);
        Console.Out.WriteLine(" runTest started...");
        ValueType vt1;
        MyStruct1 mystr1;
        MyStruct2 mystr2;
        Int64     lVal;

        try {
            mystr1 = new MyStruct1(5);
            iCountTestcases++;
            if (!mystr1.ToString().Equals("MyStruct1"))
            {
                iCountErrors++;
                Console.WriteLine("Err_53vd! ValueType change detected, please take a look");
            }
            vt1 = mystr1;
            iCountTestcases++;
            if (!vt1.ToString().Equals("MyStruct1"))
            {
                iCountErrors++;
                Console.WriteLine("Err_8536cd! ValueType change detected, please take a look");
            }
            lVal   = 50;
            mystr2 = new MyStruct2(lVal);
            iCountTestcases++;
            if (!mystr2.ToString().Equals("50"))
            {
                iCountErrors++;
                Console.WriteLine("Err_210cdp! ValueType change detected, please take a look, " + mystr2);
            }
            vt1 = mystr2;
            iCountTestcases++;
            if (!vt1.ToString().Equals("50"))
            {
                iCountErrors++;
                Console.WriteLine("Err_93246cds! ValueType change detected, please take a look, " + vt1);
            }
        }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 + "  ,iCountErrors==" + iCountErrors + " ,BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Example #16
0
    public bool NegTest11()
    {
        bool      retVal = true;
        Array     array;
        int       length;
        MyStruct2 element;
        int       index;
        int       newIndex;

        TestLibrary.TestFramework.BeginScenario("NegTest11: Array.BinarySearch(Array, int, int, object, IComparer) non-primitive type (not derived from object or IComparable)");

        try
        {
            // creat the array
            length = (TestLibrary.Generator.GetInt32(-55) % (c_MAX_SIZE-c_MIN_SIZE)) + c_MIN_SIZE;
            array  = Array.CreateInstance(typeof(MyStruct2), length);

            element = new MyStruct2(TestLibrary.Generator.GetSingle(-55));

            // fill the array
            for (int i=0; i<array.Length; i++)
            {
                do
                {
                    array.SetValue(new MyStruct2(TestLibrary.Generator.GetSingle(-55)), i);
                }
                while(element.f == ((MyStruct2)array.GetValue(i)).f);
            }

            // set the lucky index
            index = TestLibrary.Generator.GetInt32(-55) % length;

            // set the value
            array.SetValue( element, index);

            Array.Sort(array);

            newIndex = Array.BinarySearch(array, 0, array.Length, (object)element, null);

            TestLibrary.TestFramework.LogError("024", "Exception expected");
            retVal = false;
        }
        catch (InvalidOperationException)
        {
            // expected
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("025", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #17
0
 static int Main(string[] args)
 {
     int returnVal = Pass;
     MyStruct s = new MyStruct(1, 2, 3, 4);
     int sum = AddFields(s);
     if (sum != 10)
     {
         Console.WriteLine("Failed first call");
         returnVal = Fail;
     }
     s = MyStruct.newMyStruct(1, 2, 3, 4);
     sum = AddFields(s);
     if (sum != 10)
     {
         Console.WriteLine("Failed second call");
         returnVal = Fail;
     }
     MyStruct2 s2 = new MyStruct2(1, 2, 3.0, 4);
     sum = AddFields2(s2);
     if (sum != 10)
     {
         Console.WriteLine("Failed third call");
         returnVal = Fail;
     }
     MyStruct3 s3 = new MyStruct3(1, 2, 3.0, 4);
     sum = AddFields3(s3);
     if (sum != 10)
     {
         Console.WriteLine("Failed fourth call");
         returnVal = Fail;
     }
     if (returnVal == Pass)
     {
         Console.WriteLine("Pass");
     }
     return returnVal;
 }
Example #18
0
 static int AddFields2(MyStruct2 s)
 {
     return (int)(s.f1 + s.f2 + (int)s.f3 + s.f4[0]);
 }
Example #19
0
 public static int Check2(int w, int i1, int i2, int i3, int i4, int i5, int i6, int i7, MyStruct2 s2)
 {
     if ((w != 2) || (s2.f1 != i1) || (s2.f2 != i2) || (s2.f3 != i3) || (i4 != 4))
     {
         Console.WriteLine("Check2: FAIL");
         return(Fail);
     }
     Console.WriteLine("Check2: PASS");
     return(Pass);
 }
Example #20
0
 public MyStruct(SerializationInfo info, StreamingContext context)
 {
     my_ary = (byte[])info.GetValue("my_ary", typeof(byte[]));
     my_s2 = (MyStruct2)info.GetValue("my_s2", typeof(MyStruct2));
     my_int = info.GetInt32("my_int");
 }