github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/internal/math_test.go (about)

     1  package internal
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestPow(t *testing.T) {
     9  	tests := []struct {
    10  		n int
    11  		r bool
    12  	}{
    13  		{0, false},
    14  		{1, true},
    15  		{2, true},
    16  		{3, false},
    17  		{4, true},
    18  		{5, false},
    19  		{8, true},
    20  	}
    21  
    22  	for _, tt := range tests {
    23  		t.Run(fmt.Sprintf("%d", tt.n), func(t *testing.T) {
    24  			if want, got := tt.r, IsPow(tt.n); want != got {
    25  				t.Errorf("unexpected result for n %d; want: %v, got: %v", tt.n, want, got)
    26  			}
    27  		})
    28  	}
    29  }