Beispiel #1
0
        public static void RunTests()
        {
            #region 1. Addition calls

            Log.WriteLine("---Addition:");
            Log.WriteLine(" 32-32");
            Log.WriteLine("  Unsigned");
            Test_Add_UInt32_Zero_UInt32_Zero();
            Test_Add_UInt32_9_UInt32_4();
            Log.WriteLine("  Signed");
            Test_Add_Int32_9_Int32_4();
            Test_Add_Int32_9_Int32_Neg4();
            Test_Add_Int32_Neg9_Int32_4();
            Test_Add_Int32_Neg9_Int32_Neg4();
            Log.WriteLine(" 64-32");
            Log.WriteLine("  Unsigned");
            Test_Add_UInt64_LargestPos_UInt32_4();
            Log.WriteLine("  Signed");
            Test_Add_Int64_LargestPos_Int32_4();
            Test_Add_Int64_LargestNeg_Int32_4();
            Test_Add_Int64_Zero_Int32_LargestNeg();
            Log.WriteLine(" 64-64");
            Log.WriteLine("  Unsigned");
            Test_Add_UInt64_Large_UInt64_Large();
            Log.WriteLine("  Signed");
            Test_Add_Int64_LargePos_Int64_4();
            Test_Add_Int64_LargePos_Int64_LargePos();
            Test_Add_Int64_LargePos_Int64_LargeNeg();
            Test_Add_Int64_LargestNeg_Int64_Neg1();
            Test_Add_Int64_LargeNeg_Int64_LargeNeg();
            Test_Add_Int64_Zero_Int64_Neg4();
            Test_Add_Int64_Zero_Int64_LargePos();
            Test_Add_Int64_Zero_Int64_LargeNeg();
            Log.WriteLine(" ");

            #endregion

            #region 2. Subtraction calls

            Log.WriteLine("---Subtraction:");
            Log.WriteLine(" 32-32");
            Log.WriteLine("  Unsigned");
            Test_Sub_UInt32_9_UInt32_4();
            Log.WriteLine("  Signed");
            Test_Sub_Int32_9_Int32_4();
            Test_Sub_Int32_9_Int32_Neg4();
            Test_Sub_Int32_Neg9_Int32_4();
            Test_Sub_Int32_Neg9_Int32_Neg4();
            Log.WriteLine(" 64-32");
            Log.WriteLine("  Unsigned");
            Test_Sub_UInt64_LargestPos_UInt32_4();
            Log.WriteLine("  Signed");
            Test_Sub_Int64_LargestPos_Int32_4();
            Test_Sub_Int64_LargestNeg_Int32_4();
            Test_Sub_Int64_Zero_Int32_4();
            Test_Sub_Int64_Zero_Int32_LargestPos();
            Test_Sub_Int64_Zero_Int32_LargestNeg();
            Log.WriteLine(" 64-64");
            Log.WriteLine("  Unsigned");
            Test_Sub_UInt64_Large_UInt64_Large();
            Log.WriteLine("  Signed");
            Test_Sub_Int64_LargePos_Int64_4();
            Test_Sub_Int64_LargePos_Int64_LargePos();
            Test_Sub_Int64_LargePos_Int64_LargeNeg();
            Test_Sub_Int64_LargestNeg_Int64_1();
            Test_Sub_Int64_LargeNeg_Int64_LargeNeg();
            Test_Sub_Int64_Zero_Int64_4();
            Test_Sub_Int64_Zero_Int64_LargePos();
            Test_Sub_Int64_Zero_Int64_LargeNeg();
            Log.WriteLine(" ");

            #endregion

            #region 3. Multiplication calls

            Log.WriteLine("---Multiplication:");
            Log.WriteLine(" 32-32");
            Log.WriteLine("  Unsigned");
            Test_Mul_UInt32_Zero_UInt3_Zero();
            Test_Mul_UInt32_9_UInt32_4();
            Log.WriteLine("  Signed");
            Test_Mul_Int32_9_Int32_4();
            Test_Mul_Int32_9_Int32_Neg4();
            Test_Mul_Int32_Neg9_Int32_4();
            Test_Mul_Int32_Neg9_Int32_Neg4();
            Log.WriteLine(" 64-32");
            Log.WriteLine("  Unsigned");
            Test_Mul_UInt64_Zero_UInt32_Zero();
            Test_Mul_UInt64_Large_UInt32_4();
            Log.WriteLine("  Signed");
            Test_Mul_Int64_Zero_Int32_LargestNeg();
            Test_Mul_Int64_Zero_Int32_LargestPos();
            Test_Mul_Int64_LargestPos_Int32_4();
            Test_Mul_Int64_LargestPos_Int32_Neg4();
            Test_Mul_Int64_LargestNeg_Int32_4();
            Test_Mul_Int64_LargestNeg_Int32_Neg4();
            Log.WriteLine(" 64-64");
            Log.WriteLine("  Unsigned");
            Test_Mul_UInt64_Large_UInt64_Large();
            Log.WriteLine("  Signed");
            Test_Mul_Int64_Zero_Int64_LargePos();
            Test_Mul_Int64_Zero_Int64_Neg4();
            Test_Mul_Int64_LargePos_Int64_4();
            Test_Mul_Int64_LargePos_Int64_Neg4();
            Test_Mul_Int64_LargeNeg_Int64_4();
            Test_Mul_Int64_LargeNeg_Int64_Neg4();
            Test_Mul_Int64_LargePos_Int64_1000();
            Test_Mul_Int64_LargeNeg_Int64_1000();
            Test_Mul_Int64_Neg1_Int64_LargePos();
            Test_Mul_Int64_Neg1_Int64_LargeNeg();
            Test_Mul_Int64_LargestPos_Int64_Neg4();
            Test_Mul_Int64_LargestNeg_Int64_Neg4();
            Log.WriteLine(" ");

            #endregion

            #region 4. Division calls

            Log.WriteLine("---Division:");
            Log.WriteLine("  Unsigned");
            Test_Div_UInt32_9_UInt32_3();
            Test_Div_UInt32_10_UInt32_3();
            Log.WriteLine("  Signed");
            Test_Div_Int32_9_Int32_3();
            Test_Div_Int32_9_Int32_Neg3();
            Test_Div_Int32_10_Int32_3();
            Test_Div_Int32_10_Int32_Neg3();
            Test_Div_Int32_Neg9_Int32_3();
            Test_Div_Int32_Neg9_Int32_Neg3();
            Test_Div_Int32_Neg10_Int32_3();
            Test_Div_Int32_Neg10_Int32_Neg3();
            Log.WriteLine(" ");

            #endregion

            #region 5. Modulus calls

            Log.WriteLine("---Modulus:");
            Log.WriteLine("  Unsigned");
            Test_Mod_UInt32_9_UInt32_3();
            Test_Mod_UInt32_10_UInt32_3();
            Log.WriteLine("  Signed");
            Test_Mod_Int32_9_Int32_3();
            Test_Mod_Int32_9_Int32_Neg3();
            Test_Mod_Int32_10_Int32_3();
            Test_Mod_Int32_10_Int32_Neg3();
            Test_Mod_Int32_Neg9_Int32_3();
            Test_Mod_Int32_Neg9_Int32_Neg3();
            Test_Mod_Int32_Neg10_Int32_3();
            Test_Mod_Int32_Neg10_Int32_Neg3();
            Log.WriteLine(" ");

            #endregion

            #region 6. Negation calls

            Log.WriteLine("---Negation:");
            Log.WriteLine(" 32");
            Log.WriteLine("  Unsigned");
            Log.WriteLine("UInt32 cannot be negated into Int32, only into Int64 in C#.");
            Test_Neg_UInt32_Small_Int64();
            Test_Neg_UInt32_Largest_Int64();
            Log.WriteLine("  Signed");
            Test_Neg_Int32_SmallPos_Int32();
            Test_Neg_Int32_SmallNeg_Int32();
            Test_Neg_Int32_LargePos_Int64();
            Test_Neg_Int32_LargeNeg_Int64();
            Log.WriteLine(" 64");
            Log.WriteLine("  Unsigned");
            Log.WriteLine("UInt64 cannot be negated in C#.");
            Log.WriteLine("  Signed");
            Test_Neg_Int64_LargePos_Int64();
            Test_Neg_Int64_LargeNeg_Int64();
            Test_Neg_Int64_LargestPos_Int64();
            Test_Neg_Int64_LargestNeg_Int64();
            Log.WriteLine(" ");

            #endregion

            #region 7. Not calls

            Log.WriteLine("---Not:");
            Log.WriteLine(" 32");
            Log.WriteLine("  Unsigned");
            Log.WriteLine("UInt32 cannot be not-ed into Int32, only into Int64 in C#.");
            Test_Not_UInt32_Small_Int64();
            Test_Not_UInt32_Largest_Int64();
            Log.WriteLine("  Signed");
            Test_Not_Int32_SmallPos_Int32();
            Test_Not_Int32_SmallNeg_Int32();
            Test_Not_Int32_LargePos_Int64();
            Test_Not_Int32_LargeNeg_Int64();
            Log.WriteLine(" 64");
            Log.WriteLine("  Unsigned");
            Test_Not_UInt64_Smallest_UInt64();
            Test_Not_UInt64_Largest_UInt64();
            Log.WriteLine("  Signed");
            Test_Not_Int64_LargePos_Int64();
            Test_Not_Int64_LargeNeg_Int64();
            Test_Not_Int64_LargestPos_Int64();
            Test_Not_Int64_LargestNeg_Int64();
            Log.WriteLine(" ");

            #endregion

            #region 19. Xor calls

            Log.WriteLine("---Xor:");
            Test_Xor_Int();
            Log.WriteLine(" ");

            #endregion

            #region 11. Right shift calls

            Log.WriteLine("---Right shift:");
            Log.WriteLine(" 32");
            Log.WriteLine("  Unsigned");
            Test_RShift_UInt32_Small_Int32_6();
            Test_RShift_UInt32_Largest_Int32_6();
            Log.WriteLine("  Signed");
            Test_RShift_Int32_SmallPos_Int32_6();
            Test_RShift_Int32_SmallNeg_Int32_6();
            Test_RShift_Int32_LargestPos_Int32_6();
            Test_RShift_Int32_LargestNeg_Int32_6();
            Log.WriteLine(" 64");
            Log.WriteLine("  Unsigned");
            Log.WriteLine("   dist<32");
            Test_RShift_UInt64_Large_Int32_10();
            Test_RShift_UInt64_Largest_Int32_10();
            Log.WriteLine("   dist>=32");
            Test_RShift_UInt64_Largest_Int32_63();
            Log.WriteLine("  Signed");
            Log.WriteLine("   dist<32");
            Test_RShift_Int64_LargeNeg_Int32_6();
            Log.WriteLine("   dist>=32");
            Test_RShift_Int64_LargestPos_Int32_40();
            Test_RShift_Int64_LargestNeg_Int32_40();
            Test_RShift_Int64_LargeNeg_Int32_40();
            Test_RShift_Int64_Neg1_Int32_63();
            Log.WriteLine(" ");

            #endregion

            #region 12. Left shift calls

            Log.WriteLine("---Left shift:");
            Log.WriteLine(" 32");
            Log.WriteLine("  Unsigned");
            Test_LShift_UInt32_Small_Int32_6();
            Test_LShift_UInt32_Largest_Int32_6();
            Log.WriteLine("  Signed");
            Test_LShift_Int32_SmallPos_Int32_6();
            Test_LShift_Int32_SmallNeg_Int32_6();
            Test_LShift_Int32_LargestPos_Int32_6();
            Test_LShift_Int32_LargestNeg_Int32_6();
            Log.WriteLine(" 64");
            Log.WriteLine("  Unsigned");
            Log.WriteLine("   dist<32");
            Test_LShift_UInt64_Large_Int32_2();
            Test_LShift_UInt64_Largest_Int32_10();
            Log.WriteLine("   dist>=32");
            Test_LShift_UInt64_Largest_Int32_63();
            Log.WriteLine("  Signed");
            Log.WriteLine("   dist<32");
            Test_LShift_Int64_LargeNeg_Int32_6();
            Log.WriteLine("   dist>=32");
            Test_LShift_Int64_LargestPos_Int32_40();
            Test_LShift_Int64_LargestNeg_Int32_40();
            Test_LShift_Int64_LargeNeg_Int32_40();
            Test_LShift_Int64_Neg1_Int32_63();
            Log.WriteLine(" ");



            #endregion

            #region 18. Try-Catch-Finally calls

            Log.WriteLine("---Try-Catch-Finally:");
            Log.WriteLine(" TCF 0");
            Test_TCF_0();
            Log.WriteLine(" TCF 1");
            Test_TCF_1();
            Log.WriteLine(" TCF 2");
            Test_TCF_2();
            Log.WriteLine(" TCF 3");
            Test_TCF_3();
            Log.WriteLine(" TCF 4");
            Test_TCF_4();
            Log.WriteLine(" TCF 5");
            Test_TCF_5();
            Log.WriteLine(" TCF 6");
            Test_TCF_6();
            Log.WriteLine(" TCF 7");
            Test_TCF_7();
            Log.WriteLine(" ");

            #endregion
            
            #region 10. Argument calls

            // Variables used as arguments to test methods
            {
                Int32 sign32 = 6;
                Int64 sign64 = 1441151880758558720;
                UInt32 unsign32 = 100;
                UInt64 unsign64 = 10223372036854775807;
                FlingOops.String str = "I am a string";
                FlingOops.String str2 = "I am a string too";
                Log.WriteLine("---Argument:");
                Test_Arg_Int32(sign32);
                Test_Arg_Int64(sign64);
                Test_Arg_UInt32(unsign32);
                Test_Arg_UInt64(unsign64);
                Test_Arg_String(str);
                AStruct Inst = new AStruct();
                Inst.a = 1;
                Inst.b = 2;
                Inst.c = 3;
                Inst.d = 4;
                Test_Arg_Struct(Inst);
                Test_Arg_Param(sign32, sign64, unsign32, unsign64, str, str2); 
                Log.WriteLine(" ");
            }

            #endregion
                        
            #region 14. Variables and pointers calls

            Log.WriteLine("---Variables and pointers:");
            Test_Locals_And_Pointers();
            Log.WriteLine(" ");

            #endregion

            #region 13. Struct calls

            Log.WriteLine("---Struct:");
            Test_Sizeof_Struct();
            Test_Instance_Struct();
            Log.WriteLine(" ");

            #endregion

            #region 15. Switch calls

            Log.WriteLine("---Switch:");
            Log.WriteLine(" Integers");
            Test_Switch_Int32_Case_0();
            Test_Switch_Int32_Case_1();
            Test_Switch_Int32_Case_2();
            Test_Switch_Int32_Case_Default();
            Test_Switch_Int32_Case_0_Ret_NoValue();
            Log.WriteLine("  Successfully returned from Test_Switch_Int32_Case_0_Ret_NoValue()");
            Test_Switch_Int32_Case_0_Ret_IntValue();
            Log.WriteLine("  Successfully returned from Test_Switch_Int32_Case_0_Ret_IntValue()");
            Test_Switch_Int32_Case_0_Ret_StringValue();
            Log.WriteLine("  Successfully returned from Test_Switch_Int32_Case_0_Ret_StringValue()");
            Log.WriteLine(" Strings");
            Test_Switch_String_Case_0();
            Log.WriteLine(" ");

            #endregion

            #region 16. Heap calls

            Log.WriteLine("---Heap:");
            Test_Heap();
            Log.WriteLine(" ");

            #endregion
            
            #region 17. Object calls

            Log.WriteLine("---Object:");
            Test_Objects();
            Log.WriteLine(" ");

            #endregion

            #region 20. Properties

            Log.WriteLine("---Properties:");
            Test_Properties();
            Log.WriteLine(" ");

            #endregion

            #region 21. Inheritance calls

            Log.WriteLine("---Inheritance:");
            Test_Inheritance();
            Log.WriteLine(" ");

            #endregion

            #region 8. Array calls

            Log.WriteLine("---Array:");
            Log.WriteLine(" 32");
            Log.WriteLine("  Unsigned");
            Test_Array_UInt32();
            Log.WriteLine("  Signed");
            Test_Array_Int32();
            Log.WriteLine(" 64");
            Log.WriteLine("  Unsigned");
            Test_Array_UInt64();
            Log.WriteLine("  Signed");
            Test_Array_Int64();
            Log.WriteLine(" Strings");
            Test_Array_String();
            Log.WriteLine(" Structs");
            Test_Array_Struct();
            Log.WriteLine(" Objects");
            Test_Array_Object();
            Log.WriteLine(" ");

            #endregion

            #region 9. Strings calls

            Log.WriteLine("---String:");
            Test_Strings();
            Log.WriteLine(" ");

            #endregion

            Log.WriteLine("Tests completed.");
        }
Beispiel #2
0
 public static void Test_Instance_Struct()
 {
     AStruct Inst = new AStruct();
     Inst.a = 1;
     Inst.b = 2;
     Inst.c = 4;
     Inst.d = 8;
     if ((Inst.a == 1) && (Inst.b == 2) && (Inst.c == 4) && (Inst.d == 8))
     {
         Log.WriteSuccess("Test_Instance_Struct okay.");
     }
     else
     {
         Log.WriteError("Test_Instance_Struct NOT okay.");
     }
 }
Beispiel #3
0
 public static void Test_Arg_Struct(AStruct struc)
 {
     if ((struc.a == 1) && (struc.b == 2) && (struc.c == 3) && (struc.d == 4))
     {
         Log.WriteSuccess("Test_Arg_Struct okay.");
     }
     else
     {
         Log.WriteError("Test_Arg_Struct NOT okay.");
     }
 }
Beispiel #4
0
        /// <summary>
        /// Tests: Array declaration using structs as elements, 
        /// Input: An array with four elements, 
        /// Result: Correct values for each element.
        /// </summary>
        /// <remarks>
        /// <para>
        /// FlingOS does allow array declaration of the form: 
        /// int[] array = new int[4] {5, 10, 15, 20} or 
        /// int[] array = new int[] {5, 10, 15, 20}. 
        /// Array elements must be explicitly declared as in this test case. 
        /// To declare an array of strings, we need to use the FlingOS built-in string type, NOT just string because that is part of .NET.
        /// </para>
        /// </remarks>
        public static unsafe void Test_Array_Struct()
        {
            AStruct[] array = new AStruct[3];
            array[0].a = 1;
            array[0].b = 2;
            array[0].c = 4;
            array[0].d = 8;
            array[1].a = 10;
            array[1].b = 20;
            array[1].c = 40;
            array[1].d = 80;
            array[2].a = 100;
            array[2].b = 200;
            array[2].c = 400;
            array[2].d = 800;
            Int32 a = array.Length;
            if (a == 3)
            {
                Log.WriteSuccess("Test_Array_Length_Struct okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Length_Struct NOT okay.");
            }
            if (array[0].a == 1)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[0].a okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[0].a Not okay.");
            }

            if (array[0].b == 2)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[0].b okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[0].b Not okay");
            }

            if (array[0].c == 4)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[0].c okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[0].c Not okay");
            }

            if (array[0].d == 8)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[0].d okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[0].d Not okay");
            }
            if (array[1].a == 10)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[1].a okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[1].a Not okay.");
            }

            if (array[1].b == 20)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[1].b okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[1].b Not okay");
            }

            if (array[1].c == 40)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[1].c okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[1].c Not okay");
            }

            if (array[1].d == 80)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[1].d okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[1].d Not okay");
            }
            if (array[2].a == 100)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[2].a okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[2].a Not okay.");
            }

            if (array[2].b == 200)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[2].b okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[2].b Not okay");
            }

            if (array[2].c == 400)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[2].c okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[2].c Not okay");
            }

            if (array[2].d == 800)
            {
                Log.WriteSuccess("Test_Array_Decl_Struct[2].d okay.");
            }
            else
            {
                Log.WriteError("Test_Array_Decl_Struct[2].d Not okay");
            }
        }
Beispiel #5
0
 public static unsafe void Test_Static_Struct()
 {
     staticStruct = new AStruct();
     staticStruct.a = 5;
     if (staticStruct.a == 5)
     {
         Log.WriteSuccess("Test_Static_Struct staticStruct.a is 5.");
     }
     else
     {
         Log.WriteError("Test_Static_Struct staticStruct.a is not 5.");
     }
     AStruct b = staticStruct;
     if (b.a == 5)
     {
         Log.WriteSuccess("Test_Static_Struct b.a is 5.");
     }
     else
     {
         Log.WriteError("Test_Static_Struct b.a is not 5.");
     }
     b.b = 10;
     if (b.b == 10)
     {
         Log.WriteSuccess("Test_Static_Struct b.b is 10.");
     }
     else
     {
         Log.WriteError("Test_Static_Struct b.b is not 10.");
     }
     staticStruct = b;
     if (staticStruct.a == 5)
     {
         Log.WriteSuccess("Test_Static_Struct staticStruct.a is 5 (2).");
     }
     else
     {
         Log.WriteError("Test_Static_Struct staticStruct.a is not 5 (2).");
     }
     if (staticStruct.b == 10)
     {
         Log.WriteSuccess("Test_Static_Struct staticStruct.b is 10.");
     }
     else
     {
         Log.WriteError("Test_Static_Struct staticStruct.b is not 10.");
     }
 }
Beispiel #6
0
 public static void Test_Arg_Store(AStruct struc)
 {
     AStruct x = new AStruct();
     x.a = 255;
     x.b = 254;
     x.c = 253;
     x.d = 252;
     struc = x;
     if (struc.a == 255 && struc.b == 254 && struc.c == 253 && struc.d == 252)
     {
         Log.WriteSuccess("Test_Arg_Store okay.");
     }
     else
     {
         Log.WriteError("Test_Arg_Store NOT okay.");
     }
 }