예제 #1
0
func testParserResult(a assert.Assert, p Parser) {
	a.EqInt(len(p.assertions), 0)
	if len(p.assertions) != 0 {
		for _, err := range p.assertions {
			a.Errorf("assertion error: %s", err.Error())
		}
	}
	if len(p.nodeStack) != 0 {
		for _, node := range p.nodeStack {
			a.Errorf("node error:\n%s", PrintNode(node))
		}
	}
}
예제 #2
0
func checkRuleErrorCode(a assert.Assert, err error, expected RuleErrorCode) {
	a = a.Stack(1)
	if err == nil {
		a.Errorf("No error provided.")
		return
	}
	casted, ok := err.(RuleError)
	if !ok {
		a.Errorf("Invalid Error type: %s", err.Error())
		return
	}
	a.EqInt(int(casted.Code()), int(expected))
}