• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang btesting.Evaluator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cronosun/buranv1/btesting.Evaluator的典型用法代码示例。如果您正苦于以下问题:Golang Evaluator类的具体用法?Golang Evaluator怎么用?Golang Evaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Evaluator类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Eval

func Eval(e btesting.Evaluator, expecting interface{}, actual interface{}) {
	expFunction, ok := expecting.(btesting.EvalFunction)
	if !ok {
		e.T().Errorf("Unknown type")
		return
	}
	expFunction(e, actual)
}
开发者ID:cronosun,项目名称:buranv1,代码行数:8,代码来源:eval.go


示例3: Default

func Default(e btesting.Evaluator, expecting interface{}, actual interface{}) {
	expectingString := fmt.Sprintf("%v", expecting)
	actualString := fmt.Sprintf("%v", actual)

	if expectingString != actualString {
		e.T().Errorf("Expecting to have something that gives string %v "+
			"but got something that gives string %v (Default Handler)",
			expectingString, actualString)
		return
	}
}
开发者ID:cronosun,项目名称:buranv1,代码行数:11,代码来源:defaulthandler.go


示例4: 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


示例5: String

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

	if actualObj != obj {
		e.T().Errorf("Expecting string %v but got string %v", obj, actualObj)
	}
}
开发者ID:cronosun,项目名称:buranv1,代码行数:17,代码来源:string.go


示例6: ByteSlice

func ByteSlice(e btesting.Evaluator, expecting interface{}, actual interface{}) {
	obj, ok := expecting.([]byte)
	if !ok {
		e.T().Errorf("Unknown type, need []byte")
		return
	}
	actualObj, ok := actual.([]byte)
	if !ok {
		e.T().Errorf("Expecting to have a []byte but got %T, value: %v",
			actual, actual)
		return
	}
	if bytes.Compare(actualObj, obj) != 0 {
		e.T().Errorf("Given bytes %v do not match bytes %v", obj, actualObj)
		return
	}
}
开发者ID:cronosun,项目名称:buranv1,代码行数:17,代码来源:byteslice.go


示例7: Integer

func Integer(e btesting.Evaluator, expecting interface{}, actual interface{}) {
	_, _, inputAsString, inputType := toUint64OrInt64(expecting)
	if inputType == intType_notIntegerintType {
		e.T().Errorf("Input is not an integer")
		return
	}

	if actual == nil {
		e.T().Errorf("Expecting to have a integer %v but have nil",
			expecting)
		return
	}

	actualAsString := fmt.Sprintf("%v", actual)

	// Use "to string to compare"
	if inputAsString != actualAsString {
		e.T().Errorf("Expecting to have integer %v but got integer %v",
			inputAsString, actualAsString)
		return
	}
}
开发者ID:cronosun,项目名称:buranv1,代码行数:22,代码来源:integer.go


示例8: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang btesting.T类代码示例发布时间:2022-05-23
下一篇:
Golang retcode.NewStatusOk函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap