mirror of
https://github.com/tursom/GoCollections.git
synced 2025-02-26 20:20:31 +08:00
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package util
|
|
|
|
import (
|
|
"github.com/tursom/GoCollections/lang"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestStrongReference_GetReference(t *testing.T) {
|
|
type fields struct {
|
|
reference lang.Int
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
want lang.Int
|
|
}{
|
|
{"1", fields{reference: 1}, 1},
|
|
{"2", fields{reference: 2}, 2},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := NewStrongReference(tt.fields.reference)
|
|
if got := r.GetReference(); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("GetReference() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestStrongReference_SetReference(t *testing.T) {
|
|
type fields struct {
|
|
reference lang.Int
|
|
}
|
|
type args struct {
|
|
reference lang.Int
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want lang.Int
|
|
}{
|
|
{"1", fields{reference: 1}, args{2}, 2},
|
|
{"2", fields{reference: 2}, args{3}, 3},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := NewStrongReference(tt.fields.reference)
|
|
r.SetReference(tt.args.reference)
|
|
if got := r.GetReference(); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("GetReference() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|