Skip to content

Commit 1110a83

Browse files
committed
Added tests for HasZeroByte
1 parent 31f906c commit 1110a83

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

UnitTests/UnitTests.HighPerformance.Shared/Helpers/Test_BitHelper.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,43 @@ public void Test_BitHelper_HasLookupFlag32_WithMin(int x, bool flag)
7777
Assert.AreEqual(flag, BitHelper.HasLookupFlag(mask, x, 40));
7878
}
7979

80+
[TestCategory("BitHelper")]
81+
[TestMethod]
82+
[DataRow(0x0000_0000u, true)]
83+
[DataRow(0x0000_0001u, true)]
84+
[DataRow(0x0000_0011u, true)]
85+
[DataRow(0x0011_1111u, true)]
86+
[DataRow(0x1100_1111u, true)]
87+
[DataRow(0x1011_0011u, true)]
88+
[DataRow(0x1755_0055u, true)]
89+
[DataRow(0x0055_B255u, true)]
90+
[DataRow(0x1755_B200u, true)]
91+
[DataRow(0x1111_1111u, false)]
92+
[DataRow(0x1755_B255u, false)]
93+
[DataRow(0x1705_B255u, false)]
94+
[DataRow(0x1755_B055u, false)]
95+
public void Test_BitHelper_HasZeroByte_UInt32(uint x, bool result)
96+
{
97+
Assert.AreEqual(result, BitHelper.HasZeroByte(x));
98+
}
99+
100+
[TestCategory("BitHelper")]
101+
[TestMethod]
102+
[DataRow(0x0000_0000_0000_0000ul, true)]
103+
[DataRow(0x0000_0000_0000_0001ul, true)]
104+
[DataRow(0x0000_0000_0000_0011ul, true)]
105+
[DataRow(0x0011_1111_1111_1111ul, true)]
106+
[DataRow(0x1111_0011_1111_1111ul, true)]
107+
[DataRow(0x7234_AB00_DEAD_BEEFul, true)]
108+
[DataRow(0x7234_A542_DEAD_BEEFul, false)]
109+
[DataRow(0x1111_1111_1111_1111ul, false)]
110+
[DataRow(0x7234_A542_DEAD_B0EFul, false)]
111+
[DataRow(0x7030_A040_0E0D_B0E0ul, false)]
112+
public void Test_BitHelper_HasZeroByte_UInt64(ulong x, bool result)
113+
{
114+
Assert.AreEqual(result, BitHelper.HasZeroByte(x));
115+
}
116+
80117
[TestCategory("BitHelper")]
81118
[TestMethod]
82119
public void Test_BitHelper_SetFlag_UInt32()

0 commit comments

Comments
 (0)