File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 2
2
// SPDX-FileCopyrightText: 2025 Ikpil Choi([email protected] )
3
3
// SPDX-License-Identifier: MIT
4
4
5
+ using System ;
5
6
using System . Numerics ;
6
7
using NUnit . Framework ;
7
8
using static Box2D . NET . B2CTZs ;
@@ -48,4 +49,24 @@ public void Test()
48
49
Assert . That ( b2PopCount64 ( value ) , Is . EqualTo ( BitOperations . PopCount ( value ) ) , $ "PopCount64 failed for { value } ") ;
49
50
}
50
51
}
52
+
53
+ [ Test ]
54
+ public void Test_Fuzz ( )
55
+ {
56
+ var rng = new Random ( ( int ) ( DateTime . Now . Ticks / TimeSpan . TicksPerSecond ) ) ;
57
+ for ( int i = 0 ; i < 1000000 ; i ++ )
58
+ {
59
+ // 무작위 uint 생성
60
+ uint value32 = ( uint ) rng . Next ( int . MinValue , int . MaxValue ) ;
61
+ ulong value64 = ( ( ulong ) ( uint ) rng . Next ( int . MinValue , int . MaxValue ) << 32 ) | ( uint ) rng . Next ( int . MinValue , int . MaxValue ) ;
62
+
63
+ // 32비트 테스트
64
+ Assert . That ( b2CTZ32 ( value32 ) , Is . EqualTo ( BitOperations . TrailingZeroCount ( value32 ) ) , $ "CTZ32 failed for 0x{ value32 : X8} ") ;
65
+ Assert . That ( b2CLZ32 ( value32 ) , Is . EqualTo ( BitOperations . LeadingZeroCount ( value32 ) ) , $ "CLZ32 failed for 0x{ value32 : X8} ") ;
66
+
67
+ // 64비트 테스트
68
+ Assert . That ( b2CTZ64 ( value64 ) , Is . EqualTo ( BitOperations . TrailingZeroCount ( value64 ) ) , $ "CTZ64 failed for 0x{ value64 : X16} ") ;
69
+ Assert . That ( b2PopCount64 ( value64 ) , Is . EqualTo ( BitOperations . PopCount ( value64 ) ) , $ "PopCount64 failed for 0x{ value64 : X16} ") ;
70
+ }
71
+ }
51
72
}
You can’t perform that action at this time.
0 commit comments