GoDict/internal/dict/dict_merge_test.go

51 lines
1.5 KiB
Go

package dict
import (
"reflect"
"testing"
)
func TestSoftMerge(t *testing.T) {
testCases := []dictDictToDictTestCase{}
loadYamlFile("test_data/soft_merge_cases.yaml", &testCases)
for _, testCase := range testCases {
SoftMerge(&testCase.Dict1, testCase.Dict2)
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
t.Errorf("Expected dict to be %v, got %v", testCase.Result, testCase.Dict1)
}
}
}
func TestSoftMergeWith(t *testing.T) {
testCases := []dictDictToDictTestCase{}
loadYamlFile("test_data/soft_merge_cases.yaml", &testCases)
for _, testCase := range testCases {
testCase.Dict1.SoftMergeWith(testCase.Dict2)
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
t.Errorf("Expected dict to be %v, got %v", testCase.Result, testCase.Dict1)
}
}
}
func TestMerge(t *testing.T) {
testCases := []dictDictToDictTestCase{}
loadYamlFile("test_data/merge_cases.yaml", &testCases)
for _, testCase := range testCases {
Merge(&testCase.Dict1, testCase.Dict2)
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
t.Errorf("Expected dict to be %v, got %v", testCase.Result, testCase.Dict1)
}
}
}
func TestMergeWith(t *testing.T) {
testCases := []dictDictToDictTestCase{}
loadYamlFile("test_data/merge_cases.yaml", &testCases)
for _, testCase := range testCases {
testCase.Dict1.MergeWith(testCase.Dict2)
if !reflect.DeepEqual(testCase.Dict1, testCase.Result) {
t.Errorf("Expected dict to be %v, got %v", testCase.Result, testCase.Dict1)
}
}
}