Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 断言数组是用minitest排序的_Ruby_Minitest - Fatal编程技术网

Ruby 断言数组是用minitest排序的

Ruby 断言数组是用minitest排序的,ruby,minitest,Ruby,Minitest,我需要能够使用ruby编写一个minitest测试,该测试断言给定数组是由asc或desc排序的 我的代码不完整,如下所示: it "can order an array by asc order" do assert_equal tested_array, sorted_array end 你可以这样写: test "array should be sorted asc" do sorted_array = tested_array.sort assert_equal t

我需要能够使用ruby编写一个minitest测试,该测试断言给定数组是由asc或desc排序的

我的代码不完整,如下所示:

 it "can order an array by asc order" do
     assert_equal tested_array, sorted_array
end

你可以这样写:

test "array should be sorted asc" do
  sorted_array = tested_array.sort
  assert_equal tested_array, sorted_array, "Array sorted"
end

desc
相同,但要编写
tested\u array.sort.reverse
而不是
tested\u array.sort

您的问题是什么,能否提供一个代码示例?欢迎使用堆栈溢出。我们想看看你的尝试。所以,这不是一个“给我代码”的网站,而是一个“帮助我修复代码”,你的努力是非常重要的。请阅读“”和“”。@我编辑了这个问题。谢谢