Esempio n. 1
0
    public static int Main()
    {
        int[] testData = new int[] { int.MinValue, int.MinValue + 1, -1, 0, 1, 2, 1000, int.MaxValue - 1, int.MaxValue };
        for (int i = 0; i < testData.Length; i++)
        {
            for (int j = 0; j < testData.Length; j++)
            {
                // XAnd
                int test1Value = testData[i];
                int test1Arg   = testData[j];
                int ret1Value  = RefImpl.XAnd32(ref test1Value, test1Arg);

                int test2Value = testData[i];
                int test2Arg   = testData[j];
                int ret2Value  = InterlockedImpl.XAnd32(ref test2Value, test2Arg);
                AssertEquals(test1Value, test2Value);
                AssertEquals(ret1Value, ret2Value);

                // XAnd_noret
                int test3Value = testData[i];
                int test3Arg   = testData[j];
                RefImpl.XAnd32_noret(ref test3Value, test3Arg);

                int test4Value = testData[i];
                int test4Arg   = testData[j];
                InterlockedImpl.XAnd32_noret(ref test4Value, test4Arg);
                AssertEquals(test3Value, test4Value);

                // XOr
                int test5Value = testData[i];
                int test5Arg   = testData[j];
                int ret5Value  = RefImpl.XOr32(ref test5Value, test5Arg);

                int test6Value = testData[i];
                int test6Arg   = testData[j];
                int ret6Value  = InterlockedImpl.XOr32(ref test6Value, test6Arg);
                AssertEquals(test5Value, test6Value);
                AssertEquals(ret5Value, ret6Value);

                // XOr_noret
                int test7Value = testData[i];
                int test7Arg   = testData[j];
                RefImpl.XOr32_noret(ref test7Value, test7Arg);

                int test8Value = testData[i];
                int test8Arg   = testData[j];
                InterlockedImpl.XOr32_noret(ref test8Value, test8Arg);
                AssertEquals(test7Value, test8Value);
            }

            ThrowsNRE(() =>
            {
                ref int nullref = ref Unsafe.NullRef <int>();
                InterlockedImpl.XAnd32(ref nullref, testData[i]);
            });