Esempio n. 1
0
func (this *compare) CName() string {
	if this.Name == "ge" || this.Name == "le" {
		return strings.ToUpper(this.Name)
	}
	return gen.CapFirst(this.Name)
}
Esempio n. 2
0
File: main.go Progetto: katydid/v0.1
func (this *compare) CType() string {
	return gen.CapFirst(this.Type)
}
Esempio n. 3
0
File: main.go Progetto: katydid/v0.1
func (this *compare) CName() string {
	return gen.CapFirst(this.Name)
}
Esempio n. 4
0
func (this *conver) CName() string {
	return gen.CapFirst(this.Name())
}
Esempio n. 5
0
func (this *conver) CValue() string {
	if this.Type == "[]byte" {
		return "Bytes"
	}
	return gen.CapFirst(this.Type)
}
Esempio n. 6
0
func readTestFolder(path string) (*Test, error) {
	name := filepath.Base(path)
	g, err := readGrammar(path)
	if err != nil {
		return nil, err
	}
	fileInfos, err := ioutil.ReadDir(path)
	if err != nil {
		return nil, fmt.Errorf("err <%v> reading folder <%s>", err, path)
	}
	var p parser.Interface
	var expected bool
	var codecName string
	for _, fileInfo := range fileInfos {
		if fileInfo.IsDir() {
			continue
		}
		filebase := fileInfo.Name()
		filename := filepath.Join(path, filebase)
		names := strings.Split(filebase, ".")
		valid := names[0] == "valid"
		invalid := names[0] == "invalid"
		if !valid && !invalid {
			continue
		}
		expected = valid
		codecName = names[len(names)-1]
		switch codecName {
		case "pbname":
			pkgName, msgName, desc, err := getProtoDesc(filename)
			if err != nil {
				return nil, err
			}
			p, err = newProtoNameParser(pkgName, msgName, desc, filename)
			if err != nil {
				return nil, err
			}
		case "pbnum":
			pkgName, msgName, desc, err := getProtoDesc(filename)
			if err != nil {
				return nil, err
			}
			p, err = newProtoNumParser(pkgName, msgName, desc, filename)
			if err != nil {
				return nil, err
			}
		case "json":
			p, err = newJsonParser(filename)
			if err != nil {
				return nil, err
			}
		case "xml":
			p, err = newXMLParser(filename)
			if err != nil {
				return nil, err
			}
		default:
			// unsupported codec
			continue
		}
	}
	if p == nil {
		return nil, fmt.Errorf("couldn't find valid.* or invalid.* filename inside <%s>", path)
	}
	name = name + gen.CapFirst(codecName)
	return &Test{
		Name:     name,
		Grammar:  g,
		Parser:   p,
		Expected: expected,
		Record:   codecName != "xml",
	}, nil
}