github.com/tursom/GoCollections@v0.3.10/lang/Int_test.go (about) 1 /* 2 * Copyright (c) 2022 tursom. All rights reserved. 3 * Use of this source code is governed by a GPL-3 4 * license that can be found in the LICENSE file. 5 */ 6 7 package lang 8 9 import "testing" 10 11 func TestInt_Compare(t *testing.T) { 12 type args struct { 13 t Int 14 } 15 tests := []struct { 16 name string 17 i Int 18 args args 19 want int 20 }{ 21 {"", 1, args{1}, 0}, 22 {"", 1, args{0}, -1}, 23 {"", 1, args{2}, 1}, 24 } 25 for _, tt := range tests { 26 t.Run(tt.name, func(t *testing.T) { 27 if got := tt.i.Compare(tt.args.t); got != tt.want { 28 t.Errorf("Compare() = %v, want %v", got, tt.want) 29 } 30 }) 31 } 32 } 33 34 func TestInt_Equals(t *testing.T) { 35 type args struct { 36 e Object 37 } 38 tests := []struct { 39 name string 40 i Int 41 args args 42 want bool 43 }{ 44 {"", 1, args{Int(1)}, true}, 45 {"", 1, args{Int(0)}, false}, 46 {"", 1, args{Int(2)}, false}, 47 } 48 for _, tt := range tests { 49 t.Run(tt.name, func(t *testing.T) { 50 if got := tt.i.Equals(tt.args.e); got != tt.want { 51 t.Errorf("Equals() = %v, want %v", got, tt.want) 52 } 53 }) 54 } 55 } 56 57 func TestInt_String(t *testing.T) { 58 tests := []struct { 59 name string 60 i Int 61 want string 62 }{ 63 {"", 1, "1"}, 64 {"", 2, "2"}, 65 {"", 3, "3"}, 66 } 67 for _, tt := range tests { 68 t.Run(tt.name, func(t *testing.T) { 69 if got := tt.i.String(); got != tt.want { 70 t.Errorf("String() = %v, want %v", got, tt.want) 71 } 72 }) 73 } 74 }