Exemple #1
0
func Test_Config_Full(t *testing.T) {
	name := fillFile(t)

	cfg := ReadConfig(name)

	var pkg string
	pkg = cfg.packageName("a.b")
	testutil.AssertEqual(t, pkg, "ab")
	pkg = cfg.packageName("a.b.c")
	testutil.AssertEqual(t, pkg, "abc")

	var is_iface bool
	is_iface = cfg.isInterface("a.b.DEF")
	testutil.AssertTrue(t, is_iface, "a.b.DEF is not an interface")
	is_iface = cfg.isInterface("a.b.GHI")
	testutil.AssertTrue(t, is_iface, "a.b.GHI is not an interface")

	var rcvr string
	rcvr = cfg.receiver("a.b.XXX")
	testutil.AssertEqual(t, rcvr, "xxx")
	rcvr = cfg.receiver("a.b.ZZZ")
	testutil.AssertEqual(t, rcvr, "zzz")
}
Exemple #2
0
func validate(t *testing.T, str string, dim int, td *TypeData,
	fd *FakeDictionary) {
	vt, is_nil := td.TypeName()
	testutil.AssertEqual(t, dim == 0 && strings.EqualFold(str, "void"), is_nil,
		str, "should not be nil", is_nil)
	if !is_nil {
		testutil.AssertNotNil(t, vt, str, "dim", dim, "is nil ::", vt)
	}

	expName := str
	if dim == 0 {
		expName = str
	} else {
		var star string
		if fd != nil && !fd.IsInterface(str) {
			star = "*"
		}
		expName = fmt.Sprintf("array_%s%s_dim%d", star, str, dim)
	}
	testutil.AssertEqual(t, expName, td.Name(), "Expected name", expName,
		"not", td.Name())

	var expStr string
	if fd == nil || fd.IsInterface(str) {
		expStr = str
	} else {
		expStr = "*" + str
	}
	for i := 1; i <= dim; i++ {
		expStr = "[]" + expStr
	}

	testutil.AssertEqual(t, expStr, td.String(), "Expected string ", expStr,
		"not", td.String())

	if fd != nil {
		if dim == 0 {
			testutil.AssertTrue(t, td.isObject(), "Expected object", str)
		} else {
			testutil.AssertFalse(t, td.isObject(), "Unexpected object", str)
		}
	}
}