Exemplo 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]);
            });
Exemplo n.º 2
0
    public static int Main()
    {
        long[] testData = new long[] { long.MinValue, long.MinValue + 1, -1, 0, 1, 2, 1000, long.MaxValue - 1, long.MaxValue };
        for (long i = 0; i < testData.Length; i++)
        {
            for (long j = 0; j < testData.Length; j++)
            {
                // XAnd
                long test1Value = testData[i];
                long test1Arg   = testData[j];
                long ret1Value  = RefImpl.XAnd64(ref test1Value, test1Arg);

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

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

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

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

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

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

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

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