Files
gof3/tree/generic/unify_test.go
2024-02-24 12:09:33 +01:00

36 lines
961 B
Go

// Copyright Earl Warren <contact@earl-warren.org>
// Copyright Loïc Dachary <loic@dachary.org>
// SPDX-License-Identifier: MIT
package generic
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestUnifyNilRootOrigin(t *testing.T) {
ctx := context.Background()
origin := NewTestTree()
destination := NewTestTree()
destinationRoot := NewNode()
destination.SetRoot(destinationRoot)
assert.Equal(t, destinationRoot, destination.GetRoot())
TreeUnify(ctx, origin, destination, NewUnifyOptions(destination))
assert.EqualValues(t, nil, destination.GetRoot())
}
func TestUnifyNilRootDestination(t *testing.T) {
ctx := context.Background()
origin := NewTestTree()
originRoot := origin.Factory(ctx, KindTestNodeLevelOne)
origin.SetRoot(originRoot)
destination := NewTestTree()
TreeUnify(ctx, origin, destination, NewUnifyOptions(destination))
assert.EqualValues(t, KindTestNodeLevelOne, destination.GetRoot().GetKind())
}