]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/rb/spec/struct_nested_containers_spec.rb
2 # Licensed to the Apache Software Foundation (ASF) under one
3 # or more contributor license agreements. See the NOTICE file
4 # distributed with this work for additional information
5 # regarding copyright ownership. The ASF licenses this file
6 # to you under the Apache License, Version 2.0 (the
7 # "License"); you may not use this file except in compliance
8 # with the License. You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing,
13 # software distributed under the License is distributed on an
14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 # KIND, either express or implied. See the License for the
16 # specific language governing permissions and limitations
22 describe
'StructNestedContainers' do
24 def with_type_checking
25 saved_type_checking
, Thrift
.type_checking
= Thrift
.type_checking
, true
29 Thrift
.type_checking
= saved_type_checking
33 describe Thrift
::Struct do
34 # Nested container tests, see THRIFT-369.
35 it
"should support nested lists inside lists" do
37 a
, b
= SpecNamespace
::NestedListInList.new
, SpecNamespace
::NestedListInList.new
38 [a
, b
].each
do |thrift_struct
|
39 thrift_struct
.value
= [ [1, 2, 3], [2, 3, 4] ]
40 thrift_struct
.validate
43 b
.value
.push
[3, 4, 5]
44 expect(a
).not_to
eq(b
)
48 it
"should support nested lists inside sets" do
50 a
, b
= SpecNamespace
::NestedListInSet.new
, SpecNamespace
::NestedListInSet.new
51 [a
, b
].each
do |thrift_struct
|
52 thrift_struct
.value
= [ [1, 2, 3], [2, 3, 4] ].to_set
53 thrift_struct
.validate
57 expect(a
).not_to
eq(b
)
61 it
"should support nested lists in map keys" do
63 a
, b
= SpecNamespace
::NestedListInMapKey.new
, SpecNamespace
::NestedListInMapKey.new
64 [a
, b
].each
do |thrift_struct
|
65 thrift_struct
.value
= { [1, 2, 3] => 1, [2, 3, 4] => 2 }
66 thrift_struct
.validate
69 b
.value
[[3, 4, 5]] = 3
70 expect(a
).not_to
eq(b
)
74 it
"should support nested lists in map values" do
76 a
, b
= SpecNamespace
::NestedListInMapValue.new
, SpecNamespace
::NestedListInMapValue.new
77 [a
, b
].each
do |thrift_struct
|
78 thrift_struct
.value
= { 1 => [1, 2, 3], 2 => [2, 3, 4] }
79 thrift_struct
.validate
82 b
.value
[3] = [3, 4, 5]
83 expect(a
).not_to
eq(b
)
87 it
"should support nested sets inside lists" do
89 a
, b
= SpecNamespace
::NestedSetInList.new
, SpecNamespace
::NestedSetInList.new
90 [a
, b
].each
do |thrift_struct
|
91 thrift_struct
.value
= [ [1, 2, 3].to_set
, [2, 3, 4].to_set
]
92 thrift_struct
.validate
95 b
.value
.push([3, 4, 5].to_set
)
96 expect(a
).not_to
eq(b
)
100 it
"should support nested sets inside sets" do
101 with_type_checking
do
102 a
, b
= SpecNamespace
::NestedSetInSet.new
, SpecNamespace
::NestedSetInSet.new
103 [a
, b
].each
do |thrift_struct
|
104 thrift_struct
.value
= [ [1, 2, 3].to_set
, [2, 3, 4].to_set
].to_set
105 thrift_struct
.validate
108 b
.value
.add([3, 4, 5].to_set
)
109 expect(a
).not_to
eq(b
)
113 it
"should support nested sets in map keys" do
114 with_type_checking
do
115 a
, b
= SpecNamespace
::NestedSetInMapKey.new
, SpecNamespace
::NestedSetInMapKey.new
116 [a
, b
].each
do |thrift_struct
|
117 thrift_struct
.value
= { [1, 2, 3].to_set
=> 1, [2, 3, 4].to_set
=> 2 }
118 thrift_struct
.validate
121 b
.value
[[3, 4, 5].to_set
] = 3
122 expect(a
).not_to
eq(b
)
126 it
"should support nested sets in map values" do
127 with_type_checking
do
128 a
, b
= SpecNamespace
::NestedSetInMapValue.new
, SpecNamespace
::NestedSetInMapValue.new
129 [a
, b
].each
do |thrift_struct
|
130 thrift_struct
.value
= { 1 => [1, 2, 3].to_set
, 2 => [2, 3, 4].to_set
}
131 thrift_struct
.validate
134 b
.value
[3] = [3, 4, 5].to_set
135 expect(a
).not_to
eq(b
)
139 it
"should support nested maps inside lists" do
140 with_type_checking
do
141 a
, b
= SpecNamespace
::NestedMapInList.new
, SpecNamespace
::NestedMapInList.new
142 [a
, b
].each
do |thrift_struct
|
143 thrift_struct
.value
= [ {1 => 2, 3 => 4}, {2 => 3, 4 => 5} ]
144 thrift_struct
.validate
147 b
.value
.push({ 3 => 4, 5 => 6 })
148 expect(a
).not_to
eq(b
)
152 it
"should support nested maps inside sets" do
153 with_type_checking
do
154 a
, b
= SpecNamespace
::NestedMapInSet.new
, SpecNamespace
::NestedMapInSet.new
155 [a
, b
].each
do |thrift_struct
|
156 thrift_struct
.value
= [ {1 => 2, 3 => 4}, {2 => 3, 4 => 5} ].to_set
157 thrift_struct
.validate
160 b
.value
.add({ 3 => 4, 5 => 6 })
161 expect(a
).not_to
eq(b
)
165 it
"should support nested maps in map keys" do
166 with_type_checking
do
167 a
, b
= SpecNamespace
::NestedMapInMapKey.new
, SpecNamespace
::NestedMapInMapKey.new
168 [a
, b
].each
do |thrift_struct
|
169 thrift_struct
.value
= { { 1 => 2, 3 => 4} => 1, {2 => 3, 4 => 5} => 2 }
170 thrift_struct
.validate
173 b
.value
[{3 => 4, 5 => 6}] = 3
174 expect(a
).not_to
eq(b
)
178 it
"should support nested maps in map values" do
179 with_type_checking
do
180 a
, b
= SpecNamespace
::NestedMapInMapValue.new
, SpecNamespace
::NestedMapInMapValue.new
181 [a
, b
].each
do |thrift_struct
|
182 thrift_struct
.value
= { 1 => { 1 => 2, 3 => 4}, 2 => {2 => 3, 4 => 5} }
183 thrift_struct
.validate
186 b
.value
[3] = { 3 => 4, 5 => 6 }
187 expect(a
).not_to
eq(b
)