@@ -188,11 +188,38 @@ func TestFuzzyHashDistinction(t *testing.T) {
188188 }
189189 }`
190190
191+ srcBranched2 := `package main
192+ func branched2(b bool, c bool) {
193+ if b {
194+ println("branch 1")
195+ }
196+ if c {
197+ println("branch 2")
198+ }
199+ }`
200+
191201 fnLinear := testutil .CompileAndGetFunction (t , srcLinear , "linear" )
192202 fnBranched := testutil .CompileAndGetFunction (t , srcBranched , "branched" )
203+ fnBranched2 := testutil .CompileAndGetFunction (t , srcBranched2 , "branched2" )
193204
194205 topoLinear := topology .ExtractTopology (fnLinear )
195206 topoBranched := topology .ExtractTopology (fnBranched )
207+ topoBranched2 := topology .ExtractTopology (fnBranched2 )
208+
209+ // Linear: 0 branches -> BR0
210+ if ! strings .Contains (topoLinear .FuzzyHash , "BR0" ) {
211+ t .Errorf ("Linear code hash should contain BR0, got %q" , topoLinear .FuzzyHash )
212+ }
213+
214+ // Single If: 1 branch -> BR1
215+ if ! strings .Contains (topoBranched .FuzzyHash , "BR1" ) {
216+ t .Errorf ("Branched code (1 if) hash should contain BR1, got %q" , topoBranched .FuzzyHash )
217+ }
218+
219+ // Two Ifs: 2 branches -> BR2
220+ if ! strings .Contains (topoBranched2 .FuzzyHash , "BR2" ) {
221+ t .Errorf ("Branched code (2 ifs) hash should contain BR2, got %q" , topoBranched2 .FuzzyHash )
222+ }
196223
197224 if topoLinear .FuzzyHash == topoBranched .FuzzyHash {
198225 t .Errorf ("Fuzzy Hash Collision: Linear and Branched code produced same hash %q" , topoLinear .FuzzyHash )
0 commit comments