Skip to content

Commit

Permalink
put test under build guard
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Dec 19, 2024
1 parent 5833159 commit d7b63ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
16 changes: 0 additions & 16 deletions gold_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,6 @@ func (t *goldTable[V]) subnets(pfx netip.Prefix) []netip.Prefix {
}
*/

func (t *goldTable[V]) lookupPrefixReverse(pfx netip.Prefix) []netip.Prefix {
var result []netip.Prefix

for _, item := range *t {
if item.pfx.Overlaps(pfx) && item.pfx.Bits() <= pfx.Bits() {
result = append(result, item.pfx)
}
}

// b,a reverse sort order!
slices.SortFunc(result, func(a, b netip.Prefix) int {
return cmpPrefix(b, a)
})
return result
}

func (t *goldTable[V]) overlapsPrefix(pfx netip.Prefix) bool {
for _, p := range *t {
if p.pfx.Overlaps(pfx) {
Expand Down
17 changes: 17 additions & 0 deletions table_iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package bart
import (
"net/netip"
"reflect"
"slices"
"testing"
)

Expand Down Expand Up @@ -397,3 +398,19 @@ func TestSubnets(t *testing.T) {
}
}
}

func (t *goldTable[V]) lookupPrefixReverse(pfx netip.Prefix) []netip.Prefix {
var result []netip.Prefix

for _, item := range *t {
if item.pfx.Overlaps(pfx) && item.pfx.Bits() <= pfx.Bits() {
result = append(result, item.pfx)
}
}

// b,a reverse sort order!
slices.SortFunc(result, func(a, b netip.Prefix) int {
return cmpPrefix(b, a)
})
return result
}

0 comments on commit d7b63ad

Please sign in to comment.