-
Notifications
You must be signed in to change notification settings - Fork 31
/
namespace_test.go
54 lines (43 loc) · 1.63 KB
/
namespace_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package errorx
import (
"testing"
"github.com/stretchr/testify/require"
)
var (
nsTest0 = NewNamespace("nsTest0")
nsTest1 = NewNamespace("nsTest1")
nsTest1Child = nsTest1.NewSubNamespace("child")
nsTestET0 = nsTest0.NewType("type0")
nsTestET1 = nsTest1.NewType("type1")
nsTestET1Child = nsTestET1.NewSubtype("child")
nsTestChild1ET = nsTest1Child.NewType("type")
nsTestChild1ETChild = nsTestChild1ET.NewSubtype("child")
)
func TestNamespaceName(t *testing.T) {
require.EqualValues(t, "nsTest1", nsTest1.FullName())
require.EqualValues(t, "nsTest1.child", nsTest1Child.FullName())
}
func TestIsNamespaceOf(t *testing.T) {
require.True(t, nsTest0.IsNamespaceOf(nsTestET0))
require.False(t, nsTest1.IsNamespaceOf(nsTestET0))
require.False(t, nsTest0.IsNamespaceOf(nsTestET1))
require.True(t, nsTest1.IsNamespaceOf(nsTestET1))
}
func TestNamespaceSubtype(t *testing.T) {
require.False(t, nsTest0.IsNamespaceOf(nsTestET1Child))
require.True(t, nsTest1.IsNamespaceOf(nsTestET1Child))
}
func TestSubNamespace(t *testing.T) {
require.False(t, nsTest1Child.IsNamespaceOf(nsTestET1))
require.True(t, nsTest1Child.IsNamespaceOf(nsTestChild1ET))
require.True(t, nsTest1Child.IsNamespaceOf(nsTestChild1ETChild))
}
func TestRootNamespace(t *testing.T) {
require.Equal(t, nsTest1, nsTestChild1ET.NewWithNoMessage().Type().RootNamespace())
}
func TestNamespace(t *testing.T) {
require.Equal(t, nsTest1Child, nsTestChild1ET.NewWithNoMessage().Type().Namespace())
}
func TestSubTypeNamespaceFullName(t *testing.T) {
require.Equal(t, "nsTest1.child", nsTestChild1ETChild.Namespace().FullName())
}