github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/runtime/arith_test.go (about) 1 package runtime 2 3 import "testing" 4 5 func Test_floordivInt(t *testing.T) { 6 type args struct { 7 x int64 8 y int64 9 } 10 tests := []struct { 11 name string 12 args args 13 want int64 14 }{ 15 { 16 name: "-10//10", 17 args: args{ 18 x: -10, 19 y: 10, 20 }, 21 want: -1, 22 }, 23 { 24 name: "-10//-10", 25 args: args{ 26 x: -10, 27 y: -10, 28 }, 29 want: 1, 30 }, 31 { 32 name: "-10//-3", 33 args: args{ 34 x: -10, 35 y: -3, 36 }, 37 want: 3, 38 }, 39 40 { 41 name: "-10//100", 42 args: args{ 43 x: -10, 44 y: 100, 45 }, 46 want: -1, 47 }, 48 { 49 name: "-10//8", 50 args: args{ 51 x: -10, 52 y: 8, 53 }, 54 want: -2, 55 }, 56 { 57 name: "-10//-100", 58 args: args{ 59 x: -10, 60 y: -100, 61 }, 62 want: 0, 63 }, 64 } 65 for _, tt := range tests { 66 t.Run(tt.name, func(t *testing.T) { 67 if got := floordivInt(tt.args.x, tt.args.y); got != tt.want { 68 t.Errorf("floordivInt() = %v, want %v", got, tt.want) 69 } 70 }) 71 } 72 }