diff --git a/power_of_two_test.go b/power_of_two_test.go index a39e343..4841b60 100644 --- a/power_of_two_test.go +++ b/power_of_two_test.go @@ -6,16 +6,18 @@ import ( "github.com/stretchr/testify/assert" ) +const powerOfTwoMessage = "%d should be a power of 2" + func TestIsPowerOf2(t *testing.T) { // Testing the function numbers := []int{1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1048576, 70368744177664} for _, num := range numbers { - assert.True(t, IsPowerOfTwo(num), "%d should be a power of 2", num) + assert.True(t, IsPowerOfTwo(num), powerOfTwoMessage, num) } numbers = []int{-1, 0, 41, 13} for _, num := range numbers { - assert.False(t, IsPowerOfTwo(num), "%d should be a power of 2", num) + assert.False(t, IsPowerOfTwo(num), powerOfTwoMessage, num) } } @@ -25,6 +27,6 @@ func TestNextLowerPowerOf2(t *testing.T) { expected := []uint{16, 32, 64, 128, 0, 131072} for i, num := range numbers { - assert.Equal(t, expected[i], NextLowerPowerOfTwo(num), "%d should be a power of 2", num) + assert.Equal(t, expected[i], NextLowerPowerOfTwo(num), powerOfTwoMessage, num) } }