/src/System.Linq.Expressions/tests/Lifted/NonLiftedComparisonGreaterThanOrEqualNullableTests.cs
https://gitlab.com/0072016/0072016-corefx- · C# · 368 lines · 324 code · 41 blank · 3 comment · 24 complexity · 6504929c46837c699058a564a702ade2 MD5 · raw file
- // Licensed to the .NET Foundation under one or more agreements.
- // The .NET Foundation licenses this file to you under the MIT license.
- // See the LICENSE file in the project root for more information.
- using System;
- using Xunit;
- namespace System.Linq.Expressions.Tests
- {
- public static class NonLiftedComparisonGreaterThanOrEqualNullableTests
- {
- #region Test methods
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableByteTest(bool useInterpreter)
- {
- byte?[] values = new byte?[] { null, 0, 1, byte.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableByte(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableCharTest(bool useInterpreter)
- {
- char?[] values = new char?[] { null, '\0', '\b', 'A', '\uffff' };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableChar(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableDecimalTest(bool useInterpreter)
- {
- decimal?[] values = new decimal?[] { null, decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableDecimal(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableDoubleTest(bool useInterpreter)
- {
- double?[] values = new double?[] { null, 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableDouble(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableFloatTest(bool useInterpreter)
- {
- float?[] values = new float?[] { null, 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableFloat(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableIntTest(bool useInterpreter)
- {
- int?[] values = new int?[] { null, 0, 1, -1, int.MinValue, int.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableInt(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableLongTest(bool useInterpreter)
- {
- long?[] values = new long?[] { null, 0, 1, -1, long.MinValue, long.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableLong(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableSByteTest(bool useInterpreter)
- {
- sbyte?[] values = new sbyte?[] { null, 0, 1, -1, sbyte.MinValue, sbyte.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableSByte(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableShortTest(bool useInterpreter)
- {
- short?[] values = new short?[] { null, 0, 1, -1, short.MinValue, short.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableShort(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableUIntTest(bool useInterpreter)
- {
- uint?[] values = new uint?[] { null, 0, 1, uint.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableUInt(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableULongTest(bool useInterpreter)
- {
- ulong?[] values = new ulong?[] { null, 0, 1, ulong.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableULong(values[i], values[j], useInterpreter);
- }
- }
- }
- [Theory, ClassData(typeof(CompilationTypes))]
- public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableUShortTest(bool useInterpreter)
- {
- ushort?[] values = new ushort?[] { null, 0, 1, ushort.MaxValue };
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = 0; j < values.Length; j++)
- {
- VerifyComparisonGreaterThanOrEqualNullableUShort(values[i], values[j], useInterpreter);
- }
- }
- }
- #endregion
- #region Test verifiers
- private static void VerifyComparisonGreaterThanOrEqualNullableByte(byte? a, byte? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(byte?)),
- Expression.Constant(b, typeof(byte?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableChar(char? a, char? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(char?)),
- Expression.Constant(b, typeof(char?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableDecimal(decimal? a, decimal? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(decimal?)),
- Expression.Constant(b, typeof(decimal?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableDouble(double? a, double? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(double?)),
- Expression.Constant(b, typeof(double?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableFloat(float? a, float? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(float?)),
- Expression.Constant(b, typeof(float?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableInt(int? a, int? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(int?)),
- Expression.Constant(b, typeof(int?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableLong(long? a, long? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(long?)),
- Expression.Constant(b, typeof(long?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableSByte(sbyte? a, sbyte? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(sbyte?)),
- Expression.Constant(b, typeof(sbyte?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableShort(short? a, short? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(short?)),
- Expression.Constant(b, typeof(short?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableUInt(uint? a, uint? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(uint?)),
- Expression.Constant(b, typeof(uint?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableULong(ulong? a, ulong? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(ulong?)),
- Expression.Constant(b, typeof(ulong?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- private static void VerifyComparisonGreaterThanOrEqualNullableUShort(ushort? a, ushort? b, bool useInterpreter)
- {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.GreaterThanOrEqual(
- Expression.Constant(a, typeof(ushort?)),
- Expression.Constant(b, typeof(ushort?)),
- false,
- null));
- Func<bool> f = e.Compile(useInterpreter);
- bool expected = a >= b;
- bool result = f();
- Assert.Equal(expected, result);
- }
- #endregion
- }
- }