]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/ruby/red-arrow/test/test-sort-key.rb
import quincy 17.2.0
[ceph.git] / 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
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
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
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
76 key = Arrow::SortKey.new("-count", :desc)
77 assert_equal(key,
78 Arrow::SortKey.new(key.to_s))
79 end
80 end
81 end