| 16 | # under the License. |
| 17 | |
| 18 | class SortKeyTest < Test::Unit::TestCase |
| 19 | sub_test_case(".resolve") do |
| 20 | test("SortKey") do |
| 21 | assert_equal(Arrow::SortKey.new("-count"), |
| 22 | Arrow::SortKey.resolve(Arrow::SortKey.new("-count"))) |
| 23 | end |
| 24 | |
| 25 | test("-String") do |
| 26 | assert_equal(Arrow::SortKey.new("-count"), |
| 27 | Arrow::SortKey.resolve("-count")) |
| 28 | end |
| 29 | |
| 30 | test("Symbol, Symbol") do |
| 31 | assert_equal(Arrow::SortKey.new("-count"), |
| 32 | Arrow::SortKey.resolve(:count, :desc)) |
| 33 | end |
| 34 | end |
| 35 | |
| 36 | sub_test_case("#initialize") do |
| 37 | test("String") do |
| 38 | assert_equal("+count", |
| 39 | Arrow::SortKey.new("count").to_s) |
| 40 | end |
| 41 | |
| 42 | test("+String") do |
| 43 | assert_equal("+count", |
| 44 | Arrow::SortKey.new("+count").to_s) |
| 45 | end |
| 46 | |
| 47 | test("-String") do |
| 48 | assert_equal("-count", |
| 49 | Arrow::SortKey.new("-count").to_s) |
| 50 | end |
| 51 | |
| 52 | test("Symbol") do |
| 53 | assert_equal("+-count", |
| 54 | Arrow::SortKey.new(:"-count").to_s) |
| 55 | end |
| 56 | |
| 57 | test("String, Symbol") do |
| 58 | assert_equal("--count", |
| 59 | Arrow::SortKey.new("-count", :desc).to_s) |
| 60 | end |
| 61 | |
| 62 | test("String, String") do |
| 63 | assert_equal("--count", |
| 64 | Arrow::SortKey.new("-count", "desc").to_s) |
| 65 | end |
| 66 | |
| 67 | test("String, SortOrder") do |
| 68 | assert_equal("--count", |
| 69 | Arrow::SortKey.new("-count", |
| 70 | Arrow::SortOrder::DESCENDING).to_s) |
| 71 | end |
| 72 | end |
| 73 | |
| 74 | sub_test_case("#to_s") do |
| 75 | test("recreatable") do |