Test :: Unit Rails-如何断言一个数字大于另一个数字? [英] Test::Unit Rails - How to assert one number is greater than another one?

查看:101
本文介绍了Test :: Unit Rails-如何断言一个数字大于另一个数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Test :: Unit编写我的第一个单元测试,现在已经到了需要比较两个数字的地步.令我惊讶的是,我发现以下任何一个都不是可用:

I am writing my first unit tests with Test::Unit and I have reached a point where I need to compare two numbers. Much to my surprise, I have discovered that none of the following were available:

assert_greater_than
assert_lesser_than
assert_greater_or_equal_than
assert_lesser_or_equal_than

这正常吗?那我该怎么办呢?

Is this normal? How should I do it then?

谢谢

推荐答案

Test :: Unit提供了方法assert_operator,而不是像您建议的那样提供一堆不同的断言,像这样使用:

Rather than provide a bunch of different assertions as you suggest, Test::Unit provides the method assert_operator, used like this:

assert_operator x, :>, y
assert_operator x, :>=, y
etc. 

这篇关于Test :: Unit Rails-如何断言一个数字大于另一个数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆