github.com/tursom/GoCollections@v0.3.10/util/StrongReference_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 util
     8  
     9  import (
    10  	"reflect"
    11  	"testing"
    12  
    13  	"github.com/tursom/GoCollections/lang"
    14  )
    15  
    16  func TestStrongReference_GetReference(t *testing.T) {
    17  	type fields struct {
    18  		reference lang.Int
    19  	}
    20  	tests := []struct {
    21  		name   string
    22  		fields fields
    23  		want   lang.Int
    24  	}{
    25  		{"1", fields{reference: 1}, 1},
    26  		{"2", fields{reference: 2}, 2},
    27  	}
    28  	for _, tt := range tests {
    29  		t.Run(tt.name, func(t *testing.T) {
    30  			r := NewStrongReference(tt.fields.reference)
    31  			if got := r.GetReference(); !reflect.DeepEqual(got, tt.want) {
    32  				t.Errorf("GetReference() = %v, want %v", got, tt.want)
    33  			}
    34  		})
    35  	}
    36  }
    37  
    38  func TestStrongReference_SetReference(t *testing.T) {
    39  	type fields struct {
    40  		reference lang.Int
    41  	}
    42  	type args struct {
    43  		reference lang.Int
    44  	}
    45  	tests := []struct {
    46  		name   string
    47  		fields fields
    48  		args   args
    49  		want   lang.Int
    50  	}{
    51  		{"1", fields{reference: 1}, args{2}, 2},
    52  		{"2", fields{reference: 2}, args{3}, 3},
    53  	}
    54  	for _, tt := range tests {
    55  		t.Run(tt.name, func(t *testing.T) {
    56  			r := NewStrongReference(tt.fields.reference)
    57  			r.SetReference(tt.args.reference)
    58  			if got := r.GetReference(); !reflect.DeepEqual(got, tt.want) {
    59  				t.Errorf("GetReference() = %v, want %v", got, tt.want)
    60  			}
    61  		})
    62  	}
    63  }