當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Evaluator.Evaluate方法代碼示例

本文整理匯總了Golang中github.com/cronosun/buranv1/btesting.Evaluator.Evaluate方法的典型用法代碼示例。如果您正苦於以下問題:Golang Evaluator.Evaluate方法的具體用法?Golang Evaluator.Evaluate怎麽用?Golang Evaluator.Evaluate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cronosun/buranv1/btesting.Evaluator的用法示例。


在下文中一共展示了Evaluator.Evaluate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Array

func Array(e btesting.Evaluator, expecting interface{}, actual interface{}) {
	obj, ok := expecting.(btesting.Array)
	if !ok {
		e.T().Errorf("Unknown type (expecting array)")
		return
	}
	actualObj, ok := actual.([]interface{})
	if !ok {
		e.T().Errorf("Expecting to have a []interface{} but got %T, value: %v",
			actual, actual)
		return
	}

	expectingLen := len(obj)
	actualLen := len(actualObj)
	if expectingLen != actualLen {
		e.T().Errorf("Expecting both arrays to have equal length. But expecting has a length "+
			"of %v, actual has a length of %v.",
			expectingLen, actualLen)
		return
	}

	for index, v := range obj {
		e.Evaluate(v, actualObj[index])
		if e.T().Failed() {
			return
		}
	}
}
開發者ID:cronosun,項目名稱:buranv1,代碼行數:29,代碼來源:array.go

示例2: Object

func Object(e btesting.Evaluator, expecting interface{}, actual interface{}) {
	obj, ok := expecting.(btesting.Object)
	if !ok {
		e.T().Errorf("Unknown type")
		return
	}
	actualObj, ok := actual.(map[string]interface{})
	if !ok {
		e.T().Errorf("Expecting to have a map[string]interface{} but got %T, value: %v",
			actual, actual)
		return
	}

	for k, v := range obj {
		actualValue := actualObj[k]
		e.Evaluate(v, actualValue)
		if e.T().Failed() {
			return
		}
	}
}
開發者ID:cronosun,項目名稱:buranv1,代碼行數:21,代碼來源:object.go

示例3: Key

func Key(e btesting.Evaluator, expecting interface{}, actual interface{}) {
	obj, ok := expecting.(typing.Key)
	if !ok {
		e.T().Errorf("Unknown type, need typing.Key")
		return
	}

	switch actual := actual.(type) {
	case [][]byte:
		e.Evaluate(obj.ToBinary(), actual)
	case []string:
		e.Evaluate(obj.ToBase32Slice(), actual)
	case []interface{}:
		if len(actual) != len(obj) {
			e.T().Errorf("Expecting a key with %v elements but have only %v elements",
				len(obj), len(actual))
			return
		}
		for index, actualElement := range actual {
			switch actualElement := actualElement.(type) {
			case string:
				binaryElement, err := typing.Base32Decode(actualElement)
				if err != nil {
					e.T().Errorf("Error decoding key element: %v", err)
					return
				}
				e.Evaluate(obj[index], binaryElement)
				if e.T().Failed() {
					return
				}
			case []byte:
				e.Evaluate(obj[index], actualElement)
				if e.T().Failed() {
					return
				}
			default:
				e.T().Errorf("Unknown key element type (expect string or []byte): %T", actualElement)
				return
			}
		}
	default:
		e.T().Errorf("Unknown 'actual' type. Need [][]byte or []string, have: %T", actual)
	}
}
開發者ID:cronosun,項目名稱:buranv1,代碼行數:44,代碼來源:keys.go


注:本文中的github.com/cronosun/buranv1/btesting.Evaluator.Evaluate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。