public static byte[] UrlEncodeToBytes(byte[] value, int offset, int count) { throw null; }
}
}
+namespace System.Numerics
+{
+ public static class BitOperations
+ {
+ [System.CLSCompliantAttribute(false)]
+ public static int LeadingZeroCount(uint value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static int LeadingZeroCount(ulong value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static int Log2(uint value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static int Log2(ulong value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static int PopCount(uint value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static int PopCount(ulong value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static uint RotateLeft(uint value, int bitOffset) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static ulong RotateLeft(ulong value, int bitOffset) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static uint RotateRight(uint value, int bitOffset) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static ulong RotateRight(ulong value, int bitOffset) { throw null; }
+ public static int TrailingZeroCount(int value) { throw null; }
+ public static int TrailingZeroCount(long value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static int TrailingZeroCount(uint value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static int TrailingZeroCount(ulong value) { throw null; }
+ }
+}
namespace System.Reflection
{
public partial class AssemblyNameProxy : System.MarshalByRefObject
// See the LICENSE file in the project root for more information.
using System;
+using System.Numerics;
using Xunit;
-namespace Internal.Runtime.CompilerServices
+namespace System.Numerics.Tests
{
- // Dummy namespace needed for compilation of BitOps
-}
-
-namespace Tests.System
-{
- public static class BitOpsTests
+ public static class BitOperationsTests
{
[Theory]
[InlineData(0u, 32)]
[InlineData(uint.MaxValue, 0)]
public static void BitOps_LeadingZeroCount_uint(uint n, int expected)
{
- int actual = BitOps.LeadingZeroCount(n);
+ int actual = BitOperations.LeadingZeroCount(n);
Assert.Equal(expected, actual);
}
[InlineData(ulong.MaxValue, 0)]
public static void BitOps_LeadingZeroCount_ulong(ulong n, int expected)
{
- int actual = BitOps.LeadingZeroCount(n);
+ int actual = BitOperations.LeadingZeroCount(n);
Assert.Equal(expected, actual);
}
[InlineData(uint.MaxValue, 0)]
public static void BitOps_TrailingZeroCount_uint(uint n, int expected)
{
- int actual = BitOps.TrailingZeroCount(n);
+ int actual = BitOperations.TrailingZeroCount(n);
Assert.Equal(expected, actual);
}
[InlineData(int.MaxValue, 0)]
public static void BitOps_TrailingZeroCount_int(int n, int expected)
{
- int actual = BitOps.TrailingZeroCount(n);
+ int actual = BitOperations.TrailingZeroCount(n);
Assert.Equal(expected, actual);
}
[InlineData(ulong.MaxValue, 0)]
public static void BitOps_TrailingZeroCount_ulong(ulong n, int expected)
{
- int actual = BitOps.TrailingZeroCount(n);
+ int actual = BitOperations.TrailingZeroCount(n);
Assert.Equal(expected, actual);
}
[InlineData(long.MaxValue, 0)]
public static void BitOps_TrailingZeroCount_long(long n, int expected)
{
- int actual = BitOps.TrailingZeroCount(n);
+ int actual = BitOperations.TrailingZeroCount(n);
Assert.Equal(expected, actual);
}
[InlineData(uint.MaxValue, 32 - 1)]
public static void BitOps_Log2_uint(uint n, int expected)
{
- int actual = BitOps.Log2(n);
+ int actual = BitOperations.Log2(n);
Assert.Equal(expected, actual);
}
[InlineData(ulong.MaxValue, 64 - 1)]
public static void BitOps_Log2_ulong(ulong n, int expected)
{
- int actual = BitOps.Log2(n);
+ int actual = BitOperations.Log2(n);
Assert.Equal(expected, actual);
}
[InlineData(uint.MaxValue, 32)] // 4294967295
public static void BitOps_PopCount_uint(uint n, int expected)
{
- int actual = BitOps.PopCount(n);
+ int actual = BitOperations.PopCount(n);
Assert.Equal(expected, actual);
}
[InlineData(ulong.MaxValue, 64)]
public static void BitOps_PopCount_ulong(ulong n, int expected)
{
- int actual = BitOps.PopCount(n);
+ int actual = BitOperations.PopCount(n);
Assert.Equal(expected, actual);
}
[InlineData(0b01010101_11111111_01010101_01010101u, int.MinValue, 0b01010101_11111111_01010101_01010101u)] // % 32 = 0
public static void BitOps_RotateLeft_uint(uint n, int offset, uint expected)
{
- Assert.Equal(expected, BitOps.RotateLeft(n, offset));
+ Assert.Equal(expected, BitOperations.RotateLeft(n, offset));
}
[Fact]
public static void BitOps_RotateLeft_ulong()
{
ulong value = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul;
- Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, BitOps.RotateLeft(value, 1));
- Assert.Equal(0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul, BitOps.RotateLeft(value, 2));
- Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, BitOps.RotateLeft(value, 3));
- Assert.Equal(value, BitOps.RotateLeft(value, int.MinValue)); // % 64 = 0
- Assert.Equal(BitOps.RotateLeft(value, 63), BitOps.RotateLeft(value, int.MaxValue)); // % 64 = 63
+ Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, BitOperations.RotateLeft(value, 1));
+ Assert.Equal(0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul, BitOperations.RotateLeft(value, 2));
+ Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, BitOperations.RotateLeft(value, 3));
+ Assert.Equal(value, BitOperations.RotateLeft(value, int.MinValue)); // % 64 = 0
+ Assert.Equal(BitOperations.RotateLeft(value, 63), BitOperations.RotateLeft(value, int.MaxValue)); // % 64 = 63
}
[Theory]
[InlineData(0b01010101_11111111_01010101_01010101u, int.MinValue, 0b01010101_11111111_01010101_01010101u)] // % 32 = 0
public static void BitOps_RotateRight_uint(uint n, int offset, uint expected)
{
- Assert.Equal(expected, BitOps.RotateRight(n, offset));
+ Assert.Equal(expected, BitOperations.RotateRight(n, offset));
}
[Fact]
public static void BitOps_RotateRight_ulong()
{
ulong value = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul;
- Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, BitOps.RotateRight(value, 1));
- Assert.Equal(0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul, BitOps.RotateRight(value, 2));
- Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, BitOps.RotateRight(value, 3));
- Assert.Equal(value, BitOps.RotateRight(value, int.MinValue)); // % 64 = 0
- Assert.Equal(BitOps.RotateLeft(value, 63), BitOps.RotateRight(value, int.MaxValue)); // % 64 = 63
+ Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, BitOperations.RotateRight(value, 1));
+ Assert.Equal(0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul, BitOperations.RotateRight(value, 2));
+ Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, BitOperations.RotateRight(value, 3));
+ Assert.Equal(value, BitOperations.RotateRight(value, int.MinValue)); // % 64 = 0
+ Assert.Equal(BitOperations.RotateLeft(value, 63), BitOperations.RotateRight(value, int.MaxValue)); // % 64 = 63
}
}
}