]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/ruby/red-arrow/test/test-sort-key.rb
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
18 class SortKeyTest
< Test
::Unit::TestCase
19 sub_test_case(".resolve") do
21 assert_equal(Arrow
::SortKey.new("-count"),
22 Arrow
::SortKey.resolve(Arrow
::SortKey.new("-count")))
26 assert_equal(Arrow
::SortKey.new("-count"),
27 Arrow
::SortKey.resolve("-count"))
30 test("Symbol, Symbol") do
31 assert_equal(Arrow
::SortKey.new("-count"),
32 Arrow
::SortKey.resolve(:count, :desc))
36 sub_test_case("#initialize") do
38 assert_equal("+count",
39 Arrow
::SortKey.new("count").to_s
)
43 assert_equal("+count",
44 Arrow
::SortKey.new("+count").to_s
)
48 assert_equal("-count",
49 Arrow
::SortKey.new("-count").to_s
)
53 assert_equal("+-count",
54 Arrow
::SortKey.new(:"-count").to_s
)
57 test("String, Symbol") do
58 assert_equal("--count",
59 Arrow
::SortKey.new("-count", :desc).to_s
)
62 test("String, String") do
63 assert_equal("--count",
64 Arrow
::SortKey.new("-count", "desc").to_s
)
67 test("String, SortOrder") do
68 assert_equal("--count",
69 Arrow
::SortKey.new("-count",
70 Arrow
::SortOrder::DESCENDING).to_s
)
74 sub_test_case("#to_s") do
75 test("recreatable") do
76 key
= Arrow
::SortKey.new("-count", :desc)
78 Arrow
::SortKey.new(key
.to_s
))