MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestBitwiseMax

Function TestBitwiseMax

math/max/bitwisemax_test.go:10–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8import "testing"
9
10func TestBitwiseMax(t *testing.T) {
11 base32 := 31
12
13 t.Run("Testing(32bit) a = 32 and m = 64: ", func(t *testing.T) {
14 max := Bitwise(32, 64, base32)
15 if max != 64 {
16 t.Fatalf("Error: Bitwise returned bad value")
17 }
18 })
19
20 t.Run("Testing(32bit) a = 1024 and m = -9: ", func(t *testing.T) {
21 max := Bitwise(1024, -9, base32)
22 if max != 1024 {
23 t.Fatalf("Error: Bitwise returned bad value")
24 }
25 })
26
27 t.Run("Testing(32bit) a = -6 and m = -6: ", func(t *testing.T) {
28 max := Bitwise(-6, -6, base32)
29 if max != -6 {
30 t.Fatalf("Error: Bitwise returned bad value")
31 }
32 })
33
34 t.Run("Testing(32bit) a = -72 and m = -73: ", func(t *testing.T) {
35 max := Bitwise(-72, -73, base32)
36 if max != -72 {
37 t.Fatalf("Error: Bitwise returned bad value")
38 }
39 })
40
41 base64 := 63
42 t.Run("Testing(64bit) a = 32 and m = 9223372036854775807: ", func(t *testing.T) {
43 max := Bitwise(32, 9223372036854775807, base64)
44 if max != 9223372036854775807 {
45 t.Fatalf("Error: Bitwise returned bad value")
46 }
47 })
48
49 t.Run("Testing(64bit) a = 1024 and m = -9223372036854770001: ", func(t *testing.T) {
50 max := Bitwise(1024, -9223372036854770001, base64)
51 if max != 1024 {
52 t.Fatalf("Error: Bitwise returned bad value")
53 }
54 })
55
56 t.Run("Testing(64bit) a = -6 and m = -6: ", func(t *testing.T) {
57 max := Bitwise(-6, -6, base64)
58 if max != -6 {
59 t.Fatalf("Error: Bitwise returned bad value")
60 }
61 })
62
63 t.Run("Testing(64bit) a = -4223372036854775809 and m = -4223372036854775808: ", func(t *testing.T) {
64 max := Bitwise(-4223372036854775809, -4223372036854775808, base64)
65 if max != -4223372036854775808 {
66 t.Fatalf("Error: Bitwise returned bad value")
67 }

Callers

nothing calls this directly

Calls 1

BitwiseFunction · 0.70

Tested by

no test coverage detected