1fd4e5da5Sopenharmony_ci// Copyright (c) 2016 Google Inc.
2fd4e5da5Sopenharmony_ci//
3fd4e5da5Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4fd4e5da5Sopenharmony_ci// you may not use this file except in compliance with the License.
5fd4e5da5Sopenharmony_ci// You may obtain a copy of the License at
6fd4e5da5Sopenharmony_ci//
7fd4e5da5Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8fd4e5da5Sopenharmony_ci//
9fd4e5da5Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10fd4e5da5Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11fd4e5da5Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fd4e5da5Sopenharmony_ci// See the License for the specific language governing permissions and
13fd4e5da5Sopenharmony_ci// limitations under the License.
14fd4e5da5Sopenharmony_ci
15fd4e5da5Sopenharmony_ci#include "source/enum_set.h"
16fd4e5da5Sopenharmony_ci
17fd4e5da5Sopenharmony_ci#include <algorithm>
18fd4e5da5Sopenharmony_ci#include <array>
19fd4e5da5Sopenharmony_ci#include <random>
20fd4e5da5Sopenharmony_ci#include <utility>
21fd4e5da5Sopenharmony_ci#include <vector>
22fd4e5da5Sopenharmony_ci
23fd4e5da5Sopenharmony_ci#include "gmock/gmock.h"
24fd4e5da5Sopenharmony_ci#include "test/unit_spirv.h"
25fd4e5da5Sopenharmony_ci
26fd4e5da5Sopenharmony_cinamespace spvtools {
27fd4e5da5Sopenharmony_cinamespace {
28fd4e5da5Sopenharmony_ci
29fd4e5da5Sopenharmony_ciusing spvtest::ElementsIn;
30fd4e5da5Sopenharmony_ciusing ::testing::Eq;
31fd4e5da5Sopenharmony_ciusing ::testing::Values;
32fd4e5da5Sopenharmony_ciusing ::testing::ValuesIn;
33fd4e5da5Sopenharmony_ci
34fd4e5da5Sopenharmony_cienum class TestEnum : uint32_t {
35fd4e5da5Sopenharmony_ci  ZERO = 0,
36fd4e5da5Sopenharmony_ci  ONE = 1,
37fd4e5da5Sopenharmony_ci  TWO = 2,
38fd4e5da5Sopenharmony_ci  THREE = 3,
39fd4e5da5Sopenharmony_ci  FOUR = 4,
40fd4e5da5Sopenharmony_ci  FIVE = 5,
41fd4e5da5Sopenharmony_ci  EIGHT = 8,
42fd4e5da5Sopenharmony_ci  TWENTY = 20,
43fd4e5da5Sopenharmony_ci  TWENTY_FOUR = 24,
44fd4e5da5Sopenharmony_ci  THIRTY = 30,
45fd4e5da5Sopenharmony_ci  ONE_HUNDRED = 100,
46fd4e5da5Sopenharmony_ci  ONE_HUNDRED_FIFTY = 150,
47fd4e5da5Sopenharmony_ci  TWO_HUNDRED = 200,
48fd4e5da5Sopenharmony_ci  THREE_HUNDRED = 300,
49fd4e5da5Sopenharmony_ci  FOUR_HUNDRED = 400,
50fd4e5da5Sopenharmony_ci  FIVE_HUNDRED = 500,
51fd4e5da5Sopenharmony_ci  SIX_HUNDRED = 600,
52fd4e5da5Sopenharmony_ci};
53fd4e5da5Sopenharmony_ci
54fd4e5da5Sopenharmony_ciconstexpr std::array kCapabilities{
55fd4e5da5Sopenharmony_ci    spv::Capability::Matrix,
56fd4e5da5Sopenharmony_ci    spv::Capability::Shader,
57fd4e5da5Sopenharmony_ci    spv::Capability::Geometry,
58fd4e5da5Sopenharmony_ci    spv::Capability::Tessellation,
59fd4e5da5Sopenharmony_ci    spv::Capability::Addresses,
60fd4e5da5Sopenharmony_ci    spv::Capability::Linkage,
61fd4e5da5Sopenharmony_ci    spv::Capability::Kernel,
62fd4e5da5Sopenharmony_ci    spv::Capability::Vector16,
63fd4e5da5Sopenharmony_ci    spv::Capability::Float16Buffer,
64fd4e5da5Sopenharmony_ci    spv::Capability::Float16,
65fd4e5da5Sopenharmony_ci    spv::Capability::Float64,
66fd4e5da5Sopenharmony_ci    spv::Capability::Int64,
67fd4e5da5Sopenharmony_ci    spv::Capability::Int64Atomics,
68fd4e5da5Sopenharmony_ci    spv::Capability::ImageBasic,
69fd4e5da5Sopenharmony_ci    spv::Capability::ImageReadWrite,
70fd4e5da5Sopenharmony_ci    spv::Capability::ImageMipmap,
71fd4e5da5Sopenharmony_ci    spv::Capability::Pipes,
72fd4e5da5Sopenharmony_ci    spv::Capability::Groups,
73fd4e5da5Sopenharmony_ci    spv::Capability::DeviceEnqueue,
74fd4e5da5Sopenharmony_ci    spv::Capability::LiteralSampler,
75fd4e5da5Sopenharmony_ci    spv::Capability::AtomicStorage,
76fd4e5da5Sopenharmony_ci    spv::Capability::Int16,
77fd4e5da5Sopenharmony_ci    spv::Capability::TessellationPointSize,
78fd4e5da5Sopenharmony_ci    spv::Capability::GeometryPointSize,
79fd4e5da5Sopenharmony_ci    spv::Capability::ImageGatherExtended,
80fd4e5da5Sopenharmony_ci    spv::Capability::StorageImageMultisample,
81fd4e5da5Sopenharmony_ci    spv::Capability::UniformBufferArrayDynamicIndexing,
82fd4e5da5Sopenharmony_ci    spv::Capability::SampledImageArrayDynamicIndexing,
83fd4e5da5Sopenharmony_ci    spv::Capability::StorageBufferArrayDynamicIndexing,
84fd4e5da5Sopenharmony_ci    spv::Capability::StorageImageArrayDynamicIndexing,
85fd4e5da5Sopenharmony_ci    spv::Capability::ClipDistance,
86fd4e5da5Sopenharmony_ci    spv::Capability::CullDistance,
87fd4e5da5Sopenharmony_ci    spv::Capability::ImageCubeArray,
88fd4e5da5Sopenharmony_ci    spv::Capability::SampleRateShading,
89fd4e5da5Sopenharmony_ci    spv::Capability::ImageRect,
90fd4e5da5Sopenharmony_ci    spv::Capability::SampledRect,
91fd4e5da5Sopenharmony_ci    spv::Capability::GenericPointer,
92fd4e5da5Sopenharmony_ci    spv::Capability::Int8,
93fd4e5da5Sopenharmony_ci    spv::Capability::InputAttachment,
94fd4e5da5Sopenharmony_ci    spv::Capability::SparseResidency,
95fd4e5da5Sopenharmony_ci    spv::Capability::MinLod,
96fd4e5da5Sopenharmony_ci    spv::Capability::Sampled1D,
97fd4e5da5Sopenharmony_ci    spv::Capability::Image1D,
98fd4e5da5Sopenharmony_ci    spv::Capability::SampledCubeArray,
99fd4e5da5Sopenharmony_ci    spv::Capability::SampledBuffer,
100fd4e5da5Sopenharmony_ci    spv::Capability::ImageBuffer,
101fd4e5da5Sopenharmony_ci    spv::Capability::ImageMSArray,
102fd4e5da5Sopenharmony_ci    spv::Capability::StorageImageExtendedFormats,
103fd4e5da5Sopenharmony_ci    spv::Capability::ImageQuery,
104fd4e5da5Sopenharmony_ci    spv::Capability::DerivativeControl,
105fd4e5da5Sopenharmony_ci    spv::Capability::InterpolationFunction,
106fd4e5da5Sopenharmony_ci    spv::Capability::TransformFeedback,
107fd4e5da5Sopenharmony_ci    spv::Capability::GeometryStreams,
108fd4e5da5Sopenharmony_ci    spv::Capability::StorageImageReadWithoutFormat,
109fd4e5da5Sopenharmony_ci    spv::Capability::StorageImageWriteWithoutFormat,
110fd4e5da5Sopenharmony_ci    spv::Capability::MultiViewport,
111fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupDispatch,
112fd4e5da5Sopenharmony_ci    spv::Capability::NamedBarrier,
113fd4e5da5Sopenharmony_ci    spv::Capability::PipeStorage,
114fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniform,
115fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformVote,
116fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformArithmetic,
117fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformBallot,
118fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformShuffle,
119fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformShuffleRelative,
120fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformClustered,
121fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformQuad,
122fd4e5da5Sopenharmony_ci    spv::Capability::ShaderLayer,
123fd4e5da5Sopenharmony_ci    spv::Capability::ShaderViewportIndex,
124fd4e5da5Sopenharmony_ci    spv::Capability::UniformDecoration,
125fd4e5da5Sopenharmony_ci    spv::Capability::CoreBuiltinsARM,
126fd4e5da5Sopenharmony_ci    spv::Capability::FragmentShadingRateKHR,
127fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupBallotKHR,
128fd4e5da5Sopenharmony_ci    spv::Capability::DrawParameters,
129fd4e5da5Sopenharmony_ci    spv::Capability::WorkgroupMemoryExplicitLayoutKHR,
130fd4e5da5Sopenharmony_ci    spv::Capability::WorkgroupMemoryExplicitLayout8BitAccessKHR,
131fd4e5da5Sopenharmony_ci    spv::Capability::WorkgroupMemoryExplicitLayout16BitAccessKHR,
132fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupVoteKHR,
133fd4e5da5Sopenharmony_ci    spv::Capability::StorageBuffer16BitAccess,
134fd4e5da5Sopenharmony_ci    spv::Capability::StorageUniformBufferBlock16,
135fd4e5da5Sopenharmony_ci    spv::Capability::StorageUniform16,
136fd4e5da5Sopenharmony_ci    spv::Capability::UniformAndStorageBuffer16BitAccess,
137fd4e5da5Sopenharmony_ci    spv::Capability::StoragePushConstant16,
138fd4e5da5Sopenharmony_ci    spv::Capability::StorageInputOutput16,
139fd4e5da5Sopenharmony_ci    spv::Capability::DeviceGroup,
140fd4e5da5Sopenharmony_ci    spv::Capability::MultiView,
141fd4e5da5Sopenharmony_ci    spv::Capability::VariablePointersStorageBuffer,
142fd4e5da5Sopenharmony_ci    spv::Capability::VariablePointers,
143fd4e5da5Sopenharmony_ci    spv::Capability::AtomicStorageOps,
144fd4e5da5Sopenharmony_ci    spv::Capability::SampleMaskPostDepthCoverage,
145fd4e5da5Sopenharmony_ci    spv::Capability::StorageBuffer8BitAccess,
146fd4e5da5Sopenharmony_ci    spv::Capability::UniformAndStorageBuffer8BitAccess,
147fd4e5da5Sopenharmony_ci    spv::Capability::StoragePushConstant8,
148fd4e5da5Sopenharmony_ci    spv::Capability::DenormPreserve,
149fd4e5da5Sopenharmony_ci    spv::Capability::DenormFlushToZero,
150fd4e5da5Sopenharmony_ci    spv::Capability::SignedZeroInfNanPreserve,
151fd4e5da5Sopenharmony_ci    spv::Capability::RoundingModeRTE,
152fd4e5da5Sopenharmony_ci    spv::Capability::RoundingModeRTZ,
153fd4e5da5Sopenharmony_ci    spv::Capability::RayQueryProvisionalKHR,
154fd4e5da5Sopenharmony_ci    spv::Capability::RayQueryKHR,
155fd4e5da5Sopenharmony_ci    spv::Capability::RayTraversalPrimitiveCullingKHR,
156fd4e5da5Sopenharmony_ci    spv::Capability::RayTracingKHR,
157fd4e5da5Sopenharmony_ci    spv::Capability::Float16ImageAMD,
158fd4e5da5Sopenharmony_ci    spv::Capability::ImageGatherBiasLodAMD,
159fd4e5da5Sopenharmony_ci    spv::Capability::FragmentMaskAMD,
160fd4e5da5Sopenharmony_ci    spv::Capability::StencilExportEXT,
161fd4e5da5Sopenharmony_ci    spv::Capability::ImageReadWriteLodAMD,
162fd4e5da5Sopenharmony_ci    spv::Capability::Int64ImageEXT,
163fd4e5da5Sopenharmony_ci    spv::Capability::ShaderClockKHR,
164fd4e5da5Sopenharmony_ci    spv::Capability::SampleMaskOverrideCoverageNV,
165fd4e5da5Sopenharmony_ci    spv::Capability::GeometryShaderPassthroughNV,
166fd4e5da5Sopenharmony_ci    spv::Capability::ShaderViewportIndexLayerEXT,
167fd4e5da5Sopenharmony_ci    spv::Capability::ShaderViewportIndexLayerNV,
168fd4e5da5Sopenharmony_ci    spv::Capability::ShaderViewportMaskNV,
169fd4e5da5Sopenharmony_ci    spv::Capability::ShaderStereoViewNV,
170fd4e5da5Sopenharmony_ci    spv::Capability::PerViewAttributesNV,
171fd4e5da5Sopenharmony_ci    spv::Capability::FragmentFullyCoveredEXT,
172fd4e5da5Sopenharmony_ci    spv::Capability::MeshShadingNV,
173fd4e5da5Sopenharmony_ci    spv::Capability::ImageFootprintNV,
174fd4e5da5Sopenharmony_ci    spv::Capability::MeshShadingEXT,
175fd4e5da5Sopenharmony_ci    spv::Capability::FragmentBarycentricKHR,
176fd4e5da5Sopenharmony_ci    spv::Capability::FragmentBarycentricNV,
177fd4e5da5Sopenharmony_ci    spv::Capability::ComputeDerivativeGroupQuadsNV,
178fd4e5da5Sopenharmony_ci    spv::Capability::FragmentDensityEXT,
179fd4e5da5Sopenharmony_ci    spv::Capability::ShadingRateNV,
180fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformPartitionedNV,
181fd4e5da5Sopenharmony_ci    spv::Capability::ShaderNonUniform,
182fd4e5da5Sopenharmony_ci    spv::Capability::ShaderNonUniformEXT,
183fd4e5da5Sopenharmony_ci    spv::Capability::RuntimeDescriptorArray,
184fd4e5da5Sopenharmony_ci    spv::Capability::RuntimeDescriptorArrayEXT,
185fd4e5da5Sopenharmony_ci    spv::Capability::InputAttachmentArrayDynamicIndexing,
186fd4e5da5Sopenharmony_ci    spv::Capability::InputAttachmentArrayDynamicIndexingEXT,
187fd4e5da5Sopenharmony_ci    spv::Capability::UniformTexelBufferArrayDynamicIndexing,
188fd4e5da5Sopenharmony_ci    spv::Capability::UniformTexelBufferArrayDynamicIndexingEXT,
189fd4e5da5Sopenharmony_ci    spv::Capability::StorageTexelBufferArrayDynamicIndexing,
190fd4e5da5Sopenharmony_ci    spv::Capability::StorageTexelBufferArrayDynamicIndexingEXT,
191fd4e5da5Sopenharmony_ci    spv::Capability::UniformBufferArrayNonUniformIndexing,
192fd4e5da5Sopenharmony_ci    spv::Capability::UniformBufferArrayNonUniformIndexingEXT,
193fd4e5da5Sopenharmony_ci    spv::Capability::SampledImageArrayNonUniformIndexing,
194fd4e5da5Sopenharmony_ci    spv::Capability::SampledImageArrayNonUniformIndexingEXT,
195fd4e5da5Sopenharmony_ci    spv::Capability::StorageBufferArrayNonUniformIndexing,
196fd4e5da5Sopenharmony_ci    spv::Capability::StorageBufferArrayNonUniformIndexingEXT,
197fd4e5da5Sopenharmony_ci    spv::Capability::StorageImageArrayNonUniformIndexing,
198fd4e5da5Sopenharmony_ci    spv::Capability::StorageImageArrayNonUniformIndexingEXT,
199fd4e5da5Sopenharmony_ci    spv::Capability::InputAttachmentArrayNonUniformIndexing,
200fd4e5da5Sopenharmony_ci    spv::Capability::InputAttachmentArrayNonUniformIndexingEXT,
201fd4e5da5Sopenharmony_ci    spv::Capability::UniformTexelBufferArrayNonUniformIndexing,
202fd4e5da5Sopenharmony_ci    spv::Capability::UniformTexelBufferArrayNonUniformIndexingEXT,
203fd4e5da5Sopenharmony_ci    spv::Capability::StorageTexelBufferArrayNonUniformIndexing,
204fd4e5da5Sopenharmony_ci    spv::Capability::StorageTexelBufferArrayNonUniformIndexingEXT,
205fd4e5da5Sopenharmony_ci    spv::Capability::RayTracingNV,
206fd4e5da5Sopenharmony_ci    spv::Capability::RayTracingMotionBlurNV,
207fd4e5da5Sopenharmony_ci    spv::Capability::VulkanMemoryModel,
208fd4e5da5Sopenharmony_ci    spv::Capability::VulkanMemoryModelKHR,
209fd4e5da5Sopenharmony_ci    spv::Capability::VulkanMemoryModelDeviceScope,
210fd4e5da5Sopenharmony_ci    spv::Capability::VulkanMemoryModelDeviceScopeKHR,
211fd4e5da5Sopenharmony_ci    spv::Capability::PhysicalStorageBufferAddresses,
212fd4e5da5Sopenharmony_ci    spv::Capability::PhysicalStorageBufferAddressesEXT,
213fd4e5da5Sopenharmony_ci    spv::Capability::ComputeDerivativeGroupLinearNV,
214fd4e5da5Sopenharmony_ci    spv::Capability::RayTracingProvisionalKHR,
215fd4e5da5Sopenharmony_ci    spv::Capability::CooperativeMatrixNV,
216fd4e5da5Sopenharmony_ci    spv::Capability::FragmentShaderSampleInterlockEXT,
217fd4e5da5Sopenharmony_ci    spv::Capability::FragmentShaderShadingRateInterlockEXT,
218fd4e5da5Sopenharmony_ci    spv::Capability::ShaderSMBuiltinsNV,
219fd4e5da5Sopenharmony_ci    spv::Capability::FragmentShaderPixelInterlockEXT,
220fd4e5da5Sopenharmony_ci    spv::Capability::DemoteToHelperInvocation,
221fd4e5da5Sopenharmony_ci    spv::Capability::DemoteToHelperInvocationEXT,
222fd4e5da5Sopenharmony_ci    spv::Capability::RayTracingOpacityMicromapEXT,
223fd4e5da5Sopenharmony_ci    spv::Capability::ShaderInvocationReorderNV,
224fd4e5da5Sopenharmony_ci    spv::Capability::BindlessTextureNV,
225fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupShuffleINTEL,
226fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupBufferBlockIOINTEL,
227fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupImageBlockIOINTEL,
228fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupImageMediaBlockIOINTEL,
229fd4e5da5Sopenharmony_ci    spv::Capability::RoundToInfinityINTEL,
230fd4e5da5Sopenharmony_ci    spv::Capability::FloatingPointModeINTEL,
231fd4e5da5Sopenharmony_ci    spv::Capability::IntegerFunctions2INTEL,
232fd4e5da5Sopenharmony_ci    spv::Capability::FunctionPointersINTEL,
233fd4e5da5Sopenharmony_ci    spv::Capability::IndirectReferencesINTEL,
234fd4e5da5Sopenharmony_ci    spv::Capability::AsmINTEL,
235fd4e5da5Sopenharmony_ci    spv::Capability::AtomicFloat32MinMaxEXT,
236fd4e5da5Sopenharmony_ci    spv::Capability::AtomicFloat64MinMaxEXT,
237fd4e5da5Sopenharmony_ci    spv::Capability::AtomicFloat16MinMaxEXT,
238fd4e5da5Sopenharmony_ci    spv::Capability::VectorComputeINTEL,
239fd4e5da5Sopenharmony_ci    spv::Capability::VectorAnyINTEL,
240fd4e5da5Sopenharmony_ci    spv::Capability::ExpectAssumeKHR,
241fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupAvcMotionEstimationINTEL,
242fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupAvcMotionEstimationIntraINTEL,
243fd4e5da5Sopenharmony_ci    spv::Capability::SubgroupAvcMotionEstimationChromaINTEL,
244fd4e5da5Sopenharmony_ci    spv::Capability::VariableLengthArrayINTEL,
245fd4e5da5Sopenharmony_ci    spv::Capability::FunctionFloatControlINTEL,
246fd4e5da5Sopenharmony_ci    spv::Capability::FPGAMemoryAttributesINTEL,
247fd4e5da5Sopenharmony_ci    spv::Capability::FPFastMathModeINTEL,
248fd4e5da5Sopenharmony_ci    spv::Capability::ArbitraryPrecisionIntegersINTEL,
249fd4e5da5Sopenharmony_ci    spv::Capability::ArbitraryPrecisionFloatingPointINTEL,
250fd4e5da5Sopenharmony_ci    spv::Capability::UnstructuredLoopControlsINTEL,
251fd4e5da5Sopenharmony_ci    spv::Capability::FPGALoopControlsINTEL,
252fd4e5da5Sopenharmony_ci    spv::Capability::KernelAttributesINTEL,
253fd4e5da5Sopenharmony_ci    spv::Capability::FPGAKernelAttributesINTEL,
254fd4e5da5Sopenharmony_ci    spv::Capability::FPGAMemoryAccessesINTEL,
255fd4e5da5Sopenharmony_ci    spv::Capability::FPGAClusterAttributesINTEL,
256fd4e5da5Sopenharmony_ci    spv::Capability::LoopFuseINTEL,
257fd4e5da5Sopenharmony_ci    spv::Capability::FPGADSPControlINTEL,
258fd4e5da5Sopenharmony_ci    spv::Capability::MemoryAccessAliasingINTEL,
259fd4e5da5Sopenharmony_ci    spv::Capability::FPGAInvocationPipeliningAttributesINTEL,
260fd4e5da5Sopenharmony_ci    spv::Capability::FPGABufferLocationINTEL,
261fd4e5da5Sopenharmony_ci    spv::Capability::ArbitraryPrecisionFixedPointINTEL,
262fd4e5da5Sopenharmony_ci    spv::Capability::USMStorageClassesINTEL,
263fd4e5da5Sopenharmony_ci    spv::Capability::RuntimeAlignedAttributeINTEL,
264fd4e5da5Sopenharmony_ci    spv::Capability::IOPipesINTEL,
265fd4e5da5Sopenharmony_ci    spv::Capability::BlockingPipesINTEL,
266fd4e5da5Sopenharmony_ci    spv::Capability::FPGARegINTEL,
267fd4e5da5Sopenharmony_ci    spv::Capability::DotProductInputAll,
268fd4e5da5Sopenharmony_ci    spv::Capability::DotProductInputAllKHR,
269fd4e5da5Sopenharmony_ci    spv::Capability::DotProductInput4x8Bit,
270fd4e5da5Sopenharmony_ci    spv::Capability::DotProductInput4x8BitKHR,
271fd4e5da5Sopenharmony_ci    spv::Capability::DotProductInput4x8BitPacked,
272fd4e5da5Sopenharmony_ci    spv::Capability::DotProductInput4x8BitPackedKHR,
273fd4e5da5Sopenharmony_ci    spv::Capability::DotProduct,
274fd4e5da5Sopenharmony_ci    spv::Capability::DotProductKHR,
275fd4e5da5Sopenharmony_ci    spv::Capability::RayCullMaskKHR,
276fd4e5da5Sopenharmony_ci    spv::Capability::BitInstructions,
277fd4e5da5Sopenharmony_ci    spv::Capability::GroupNonUniformRotateKHR,
278fd4e5da5Sopenharmony_ci    spv::Capability::AtomicFloat32AddEXT,
279fd4e5da5Sopenharmony_ci    spv::Capability::AtomicFloat64AddEXT,
280fd4e5da5Sopenharmony_ci    spv::Capability::LongCompositesINTEL,
281fd4e5da5Sopenharmony_ci    spv::Capability::OptNoneINTEL,
282fd4e5da5Sopenharmony_ci    spv::Capability::AtomicFloat16AddEXT,
283fd4e5da5Sopenharmony_ci    spv::Capability::DebugInfoModuleINTEL,
284fd4e5da5Sopenharmony_ci    spv::Capability::SplitBarrierINTEL,
285fd4e5da5Sopenharmony_ci    spv::Capability::GroupUniformArithmeticKHR,
286fd4e5da5Sopenharmony_ci    spv::Capability::Max,
287fd4e5da5Sopenharmony_ci};
288fd4e5da5Sopenharmony_ci
289fd4e5da5Sopenharmony_cinamespace {
290fd4e5da5Sopenharmony_cistd::vector<TestEnum> enumerateValuesFromToWithStep(size_t start, size_t end,
291fd4e5da5Sopenharmony_ci                                                    size_t step) {
292fd4e5da5Sopenharmony_ci  assert(end > start && "end > start");
293fd4e5da5Sopenharmony_ci  std::vector<TestEnum> orderedValues;
294fd4e5da5Sopenharmony_ci  for (size_t i = start; i < end; i += step) {
295fd4e5da5Sopenharmony_ci    orderedValues.push_back(static_cast<TestEnum>(i));
296fd4e5da5Sopenharmony_ci  }
297fd4e5da5Sopenharmony_ci  return orderedValues;
298fd4e5da5Sopenharmony_ci}
299fd4e5da5Sopenharmony_ci
300fd4e5da5Sopenharmony_ciEnumSet<TestEnum> createSetUnorderedInsertion(
301fd4e5da5Sopenharmony_ci    const std::vector<TestEnum>& values) {
302fd4e5da5Sopenharmony_ci  std::vector shuffledValues(values.cbegin(), values.cend());
303fd4e5da5Sopenharmony_ci  std::mt19937 rng(0);
304fd4e5da5Sopenharmony_ci  std::shuffle(shuffledValues.begin(), shuffledValues.end(), rng);
305fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
306fd4e5da5Sopenharmony_ci  for (auto value : shuffledValues) {
307fd4e5da5Sopenharmony_ci    set.insert(value);
308fd4e5da5Sopenharmony_ci  }
309fd4e5da5Sopenharmony_ci  return set;
310fd4e5da5Sopenharmony_ci}
311fd4e5da5Sopenharmony_ci}  // namespace
312fd4e5da5Sopenharmony_ci
313fd4e5da5Sopenharmony_ciTEST(EnumSet, IsEmpty1) {
314fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
315fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.empty());
316fd4e5da5Sopenharmony_ci  set.insert(TestEnum::ZERO);
317fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.empty());
318fd4e5da5Sopenharmony_ci}
319fd4e5da5Sopenharmony_ci
320fd4e5da5Sopenharmony_ciTEST(EnumSet, IsEmpty2) {
321fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
322fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.empty());
323fd4e5da5Sopenharmony_ci  set.insert(TestEnum::ONE_HUNDRED_FIFTY);
324fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.empty());
325fd4e5da5Sopenharmony_ci}
326fd4e5da5Sopenharmony_ci
327fd4e5da5Sopenharmony_ciTEST(EnumSet, IsEmpty3) {
328fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set(TestEnum::FOUR);
329fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.empty());
330fd4e5da5Sopenharmony_ci}
331fd4e5da5Sopenharmony_ci
332fd4e5da5Sopenharmony_ciTEST(EnumSet, IsEmpty4) {
333fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set(TestEnum::THREE_HUNDRED);
334fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.empty());
335fd4e5da5Sopenharmony_ci}
336fd4e5da5Sopenharmony_ci
337fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, EmptySetEmptyQuery) {
338fd4e5da5Sopenharmony_ci  const EnumSet<TestEnum> set;
339fd4e5da5Sopenharmony_ci  const EnumSet<TestEnum> empty;
340fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(empty));
341fd4e5da5Sopenharmony_ci  EXPECT_TRUE(EnumSet<TestEnum>().HasAnyOf(EnumSet<TestEnum>()));
342fd4e5da5Sopenharmony_ci}
343fd4e5da5Sopenharmony_ci
344fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, MaskSetEmptyQuery) {
345fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
346fd4e5da5Sopenharmony_ci  const EnumSet<TestEnum> empty;
347fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FIVE);
348fd4e5da5Sopenharmony_ci  set.insert(TestEnum::EIGHT);
349fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(empty));
350fd4e5da5Sopenharmony_ci}
351fd4e5da5Sopenharmony_ci
352fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, OverflowSetEmptyQuery) {
353fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
354fd4e5da5Sopenharmony_ci  const EnumSet<TestEnum> empty;
355fd4e5da5Sopenharmony_ci  set.insert(TestEnum::TWO_HUNDRED);
356fd4e5da5Sopenharmony_ci  set.insert(TestEnum::THREE_HUNDRED);
357fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(empty));
358fd4e5da5Sopenharmony_ci}
359fd4e5da5Sopenharmony_ci
360fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, EmptyQuery) {
361fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
362fd4e5da5Sopenharmony_ci  const EnumSet<TestEnum> empty;
363fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FIVE);
364fd4e5da5Sopenharmony_ci  set.insert(TestEnum::EIGHT);
365fd4e5da5Sopenharmony_ci  set.insert(TestEnum::TWO_HUNDRED);
366fd4e5da5Sopenharmony_ci  set.insert(TestEnum::THREE_HUNDRED);
367fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(empty));
368fd4e5da5Sopenharmony_ci}
369fd4e5da5Sopenharmony_ci
370fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, EmptyQueryAlwaysTrue) {
371fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
372fd4e5da5Sopenharmony_ci  const EnumSet<TestEnum> empty;
373fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(empty));
374fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FIVE);
375fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(empty));
376fd4e5da5Sopenharmony_ci
377fd4e5da5Sopenharmony_ci  EXPECT_TRUE(
378fd4e5da5Sopenharmony_ci      EnumSet<TestEnum>(TestEnum::ONE_HUNDRED).HasAnyOf(EnumSet<TestEnum>()));
379fd4e5da5Sopenharmony_ci}
380fd4e5da5Sopenharmony_ci
381fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, ReflexiveMask) {
382fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set(TestEnum::THREE);
383fd4e5da5Sopenharmony_ci  set.insert(TestEnum::TWENTY_FOUR);
384fd4e5da5Sopenharmony_ci  set.insert(TestEnum::THIRTY);
385fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(set));
386fd4e5da5Sopenharmony_ci}
387fd4e5da5Sopenharmony_ci
388fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, ReflexiveOverflow) {
389fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set(TestEnum::TWO_HUNDRED);
390fd4e5da5Sopenharmony_ci  set.insert(TestEnum::TWO_HUNDRED);
391fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FOUR_HUNDRED);
392fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(set));
393fd4e5da5Sopenharmony_ci}
394fd4e5da5Sopenharmony_ci
395fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, Reflexive) {
396fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set(TestEnum::THREE);
397fd4e5da5Sopenharmony_ci  set.insert(TestEnum::TWENTY_FOUR);
398fd4e5da5Sopenharmony_ci  set.insert(TestEnum::THREE_HUNDRED);
399fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FOUR_HUNDRED);
400fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(set));
401fd4e5da5Sopenharmony_ci}
402fd4e5da5Sopenharmony_ci
403fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, EmptySetHasNone) {
404fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
405fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> items;
406fd4e5da5Sopenharmony_ci  for (uint32_t i = 0; i < 200; ++i) {
407fd4e5da5Sopenharmony_ci    TestEnum enumValue = static_cast<TestEnum>(i);
408fd4e5da5Sopenharmony_ci    items.insert(enumValue);
409fd4e5da5Sopenharmony_ci    EXPECT_FALSE(set.HasAnyOf(items));
410fd4e5da5Sopenharmony_ci    EXPECT_FALSE(set.HasAnyOf(EnumSet<TestEnum>(enumValue)));
411fd4e5da5Sopenharmony_ci  }
412fd4e5da5Sopenharmony_ci}
413fd4e5da5Sopenharmony_ci
414fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, MaskSetMaskQuery) {
415fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set(TestEnum::ZERO);
416fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> items(TestEnum::ONE);
417fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(items));
418fd4e5da5Sopenharmony_ci  set.insert(TestEnum::TWO);
419fd4e5da5Sopenharmony_ci  items.insert(TestEnum::THREE);
420fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(items));
421fd4e5da5Sopenharmony_ci  set.insert(TestEnum::THREE);
422fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(items));
423fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FOUR);
424fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(items));
425fd4e5da5Sopenharmony_ci}
426fd4e5da5Sopenharmony_ci
427fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, OverflowSetOverflowQuery) {
428fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set(TestEnum::ONE_HUNDRED);
429fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> items(TestEnum::TWO_HUNDRED);
430fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(items));
431fd4e5da5Sopenharmony_ci  set.insert(TestEnum::THREE_HUNDRED);
432fd4e5da5Sopenharmony_ci  items.insert(TestEnum::FOUR_HUNDRED);
433fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(items));
434fd4e5da5Sopenharmony_ci  set.insert(TestEnum::TWO_HUNDRED);
435fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(items));
436fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FIVE_HUNDRED);
437fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(items));
438fd4e5da5Sopenharmony_ci}
439fd4e5da5Sopenharmony_ci
440fd4e5da5Sopenharmony_ciTEST(EnumSetHasAnyOf, GeneralCase) {
441fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set(TestEnum::ZERO);
442fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> items(TestEnum::ONE_HUNDRED);
443fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(items));
444fd4e5da5Sopenharmony_ci  set.insert(TestEnum::THREE_HUNDRED);
445fd4e5da5Sopenharmony_ci  items.insert(TestEnum::FOUR);
446fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(items));
447fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FIVE);
448fd4e5da5Sopenharmony_ci  items.insert(TestEnum::FIVE_HUNDRED);
449fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(items));
450fd4e5da5Sopenharmony_ci  set.insert(TestEnum::FIVE_HUNDRED);
451fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(items));
452fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(EnumSet<TestEnum>(TestEnum::TWENTY)));
453fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.HasAnyOf(EnumSet<TestEnum>(TestEnum::SIX_HUNDRED)));
454fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(EnumSet<TestEnum>(TestEnum::FIVE)));
455fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(EnumSet<TestEnum>(TestEnum::THREE_HUNDRED)));
456fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.HasAnyOf(EnumSet<TestEnum>(TestEnum::ZERO)));
457fd4e5da5Sopenharmony_ci}
458fd4e5da5Sopenharmony_ci
459fd4e5da5Sopenharmony_ciTEST(EnumSet, DefaultIsEmpty) {
460fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set;
461fd4e5da5Sopenharmony_ci  for (uint32_t i = 0; i < 1000; ++i) {
462fd4e5da5Sopenharmony_ci    EXPECT_FALSE(set.contains(static_cast<TestEnum>(i)));
463fd4e5da5Sopenharmony_ci  }
464fd4e5da5Sopenharmony_ci}
465fd4e5da5Sopenharmony_ci
466fd4e5da5Sopenharmony_ciTEST(EnumSet, EqualityCompareEmpty) {
467fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set1;
468fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set2;
469fd4e5da5Sopenharmony_ci
470fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set1 == set2);
471fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set1 != set2);
472fd4e5da5Sopenharmony_ci}
473fd4e5da5Sopenharmony_ci
474fd4e5da5Sopenharmony_ciTEST(EnumSet, EqualityCompareSame) {
475fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set1;
476fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set2;
477fd4e5da5Sopenharmony_ci
478fd4e5da5Sopenharmony_ci  set1.insert(TestEnum::ONE);
479fd4e5da5Sopenharmony_ci  set1.insert(TestEnum::TWENTY);
480fd4e5da5Sopenharmony_ci  set2.insert(TestEnum::TWENTY);
481fd4e5da5Sopenharmony_ci  set2.insert(TestEnum::ONE);
482fd4e5da5Sopenharmony_ci
483fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set1 == set2);
484fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set1 != set2);
485fd4e5da5Sopenharmony_ci}
486fd4e5da5Sopenharmony_ci
487fd4e5da5Sopenharmony_ciTEST(EnumSet, EqualityCompareDifferent) {
488fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set1;
489fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set2;
490fd4e5da5Sopenharmony_ci
491fd4e5da5Sopenharmony_ci  set1.insert(TestEnum::ONE);
492fd4e5da5Sopenharmony_ci  set1.insert(TestEnum::TWENTY);
493fd4e5da5Sopenharmony_ci  set2.insert(TestEnum::FIVE);
494fd4e5da5Sopenharmony_ci  set2.insert(TestEnum::ONE);
495fd4e5da5Sopenharmony_ci
496fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set1 == set2);
497fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set1 != set2);
498fd4e5da5Sopenharmony_ci}
499fd4e5da5Sopenharmony_ci
500fd4e5da5Sopenharmony_ciTEST(EnumSet, ConstructFromIterators) {
501fd4e5da5Sopenharmony_ci  auto orderedValues = enumerateValuesFromToWithStep(0, 2, /* step= */ 1);
502fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set1 = createSetUnorderedInsertion(orderedValues);
503fd4e5da5Sopenharmony_ci
504fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set2(orderedValues.cbegin(), orderedValues.cend());
505fd4e5da5Sopenharmony_ci
506fd4e5da5Sopenharmony_ci  EXPECT_EQ(set1, set2);
507fd4e5da5Sopenharmony_ci}
508fd4e5da5Sopenharmony_ci
509fd4e5da5Sopenharmony_ciTEST(EnumSet, InsertUsingIteratorRange) {
510fd4e5da5Sopenharmony_ci  auto orderedValues = enumerateValuesFromToWithStep(0, 2, /* step= */ 1);
511fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set1 = createSetUnorderedInsertion(orderedValues);
512fd4e5da5Sopenharmony_ci
513fd4e5da5Sopenharmony_ci  EnumSet<TestEnum> set2;
514fd4e5da5Sopenharmony_ci  set2.insert(orderedValues.cbegin(), orderedValues.cend());
515fd4e5da5Sopenharmony_ci
516fd4e5da5Sopenharmony_ci  EXPECT_EQ(set1, set2);
517fd4e5da5Sopenharmony_ci}
518fd4e5da5Sopenharmony_ci
519fd4e5da5Sopenharmony_ciTEST(CapabilitySet, RangeBasedLoopOrderIsEnumOrder) {
520fd4e5da5Sopenharmony_ci  auto orderedValues = enumerateValuesFromToWithStep(0, 2, /* step= */ 1);
521fd4e5da5Sopenharmony_ci  auto set = createSetUnorderedInsertion(orderedValues);
522fd4e5da5Sopenharmony_ci
523fd4e5da5Sopenharmony_ci  size_t index = 0;
524fd4e5da5Sopenharmony_ci  for (auto value : set) {
525fd4e5da5Sopenharmony_ci    ASSERT_THAT(value, Eq(orderedValues[index]));
526fd4e5da5Sopenharmony_ci    index++;
527fd4e5da5Sopenharmony_ci  }
528fd4e5da5Sopenharmony_ci}
529fd4e5da5Sopenharmony_ci
530fd4e5da5Sopenharmony_ciTEST(CapabilitySet, ConstructSingleMemberMatrix) {
531fd4e5da5Sopenharmony_ci  CapabilitySet s(spv::Capability::Matrix);
532fd4e5da5Sopenharmony_ci  EXPECT_TRUE(s.contains(spv::Capability::Matrix));
533fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(spv::Capability::Shader));
534fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(static_cast<spv::Capability>(1000)));
535fd4e5da5Sopenharmony_ci}
536fd4e5da5Sopenharmony_ci
537fd4e5da5Sopenharmony_ciTEST(CapabilitySet, ConstructSingleMemberMaxInMask) {
538fd4e5da5Sopenharmony_ci  CapabilitySet s(static_cast<spv::Capability>(63));
539fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(spv::Capability::Matrix));
540fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(spv::Capability::Shader));
541fd4e5da5Sopenharmony_ci  EXPECT_TRUE(s.contains(static_cast<spv::Capability>(63)));
542fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(static_cast<spv::Capability>(64)));
543fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(static_cast<spv::Capability>(1000)));
544fd4e5da5Sopenharmony_ci}
545fd4e5da5Sopenharmony_ci
546fd4e5da5Sopenharmony_ciTEST(CapabilitySet, ConstructSingleMemberMinOverflow) {
547fd4e5da5Sopenharmony_ci  // Check the first one that forces overflow beyond the mask.
548fd4e5da5Sopenharmony_ci  CapabilitySet s(static_cast<spv::Capability>(64));
549fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(spv::Capability::Matrix));
550fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(spv::Capability::Shader));
551fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(static_cast<spv::Capability>(63)));
552fd4e5da5Sopenharmony_ci  EXPECT_TRUE(s.contains(static_cast<spv::Capability>(64)));
553fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(static_cast<spv::Capability>(1000)));
554fd4e5da5Sopenharmony_ci}
555fd4e5da5Sopenharmony_ci
556fd4e5da5Sopenharmony_ciTEST(CapabilitySet, ConstructSingleMemberMaxOverflow) {
557fd4e5da5Sopenharmony_ci  // Check the max 32-bit signed int.
558fd4e5da5Sopenharmony_ci  CapabilitySet s(static_cast<spv::Capability>(0x7fffffffu));
559fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(spv::Capability::Matrix));
560fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(spv::Capability::Shader));
561fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(static_cast<spv::Capability>(1000)));
562fd4e5da5Sopenharmony_ci  EXPECT_TRUE(s.contains(static_cast<spv::Capability>(0x7fffffffu)));
563fd4e5da5Sopenharmony_ci}
564fd4e5da5Sopenharmony_ci
565fd4e5da5Sopenharmony_ciTEST(CapabilitySet, AddEnum) {
566fd4e5da5Sopenharmony_ci  CapabilitySet s(spv::Capability::Shader);
567fd4e5da5Sopenharmony_ci  s.insert(spv::Capability::Kernel);
568fd4e5da5Sopenharmony_ci  s.insert(static_cast<spv::Capability>(42));
569fd4e5da5Sopenharmony_ci  EXPECT_FALSE(s.contains(spv::Capability::Matrix));
570fd4e5da5Sopenharmony_ci  EXPECT_TRUE(s.contains(spv::Capability::Shader));
571fd4e5da5Sopenharmony_ci  EXPECT_TRUE(s.contains(spv::Capability::Kernel));
572fd4e5da5Sopenharmony_ci  EXPECT_TRUE(s.contains(static_cast<spv::Capability>(42)));
573fd4e5da5Sopenharmony_ci}
574fd4e5da5Sopenharmony_ci
575fd4e5da5Sopenharmony_ciTEST(CapabilitySet, InsertReturnsIteratorToInserted) {
576fd4e5da5Sopenharmony_ci  CapabilitySet set;
577fd4e5da5Sopenharmony_ci
578fd4e5da5Sopenharmony_ci  auto[it, inserted] = set.insert(spv::Capability::Kernel);
579fd4e5da5Sopenharmony_ci
580fd4e5da5Sopenharmony_ci  EXPECT_TRUE(inserted);
581fd4e5da5Sopenharmony_ci  EXPECT_EQ(*it, spv::Capability::Kernel);
582fd4e5da5Sopenharmony_ci}
583fd4e5da5Sopenharmony_ci
584fd4e5da5Sopenharmony_ciTEST(CapabilitySet, InsertReturnsIteratorToElementOnDoubleInsertion) {
585fd4e5da5Sopenharmony_ci  CapabilitySet set;
586fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.contains(spv::Capability::Shader));
587fd4e5da5Sopenharmony_ci  {
588fd4e5da5Sopenharmony_ci    auto[it, inserted] = set.insert(spv::Capability::Shader);
589fd4e5da5Sopenharmony_ci    EXPECT_TRUE(inserted);
590fd4e5da5Sopenharmony_ci    EXPECT_EQ(*it, spv::Capability::Shader);
591fd4e5da5Sopenharmony_ci  }
592fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.contains(spv::Capability::Shader));
593fd4e5da5Sopenharmony_ci
594fd4e5da5Sopenharmony_ci  auto[it, inserted] = set.insert(spv::Capability::Shader);
595fd4e5da5Sopenharmony_ci
596fd4e5da5Sopenharmony_ci  EXPECT_FALSE(inserted);
597fd4e5da5Sopenharmony_ci  EXPECT_EQ(*it, spv::Capability::Shader);
598fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.contains(spv::Capability::Shader));
599fd4e5da5Sopenharmony_ci}
600fd4e5da5Sopenharmony_ci
601fd4e5da5Sopenharmony_ciTEST(CapabilitySet, InsertWithHintWorks) {
602fd4e5da5Sopenharmony_ci  CapabilitySet set;
603fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.contains(spv::Capability::Shader));
604fd4e5da5Sopenharmony_ci
605fd4e5da5Sopenharmony_ci  auto it = set.insert(set.begin(), spv::Capability::Shader);
606fd4e5da5Sopenharmony_ci
607fd4e5da5Sopenharmony_ci  EXPECT_EQ(*it, spv::Capability::Shader);
608fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.contains(spv::Capability::Shader));
609fd4e5da5Sopenharmony_ci}
610fd4e5da5Sopenharmony_ci
611fd4e5da5Sopenharmony_ciTEST(CapabilitySet, InsertWithEndHintWorks) {
612fd4e5da5Sopenharmony_ci  CapabilitySet set;
613fd4e5da5Sopenharmony_ci  EXPECT_FALSE(set.contains(spv::Capability::Shader));
614fd4e5da5Sopenharmony_ci
615fd4e5da5Sopenharmony_ci  auto it = set.insert(set.end(), spv::Capability::Shader);
616fd4e5da5Sopenharmony_ci
617fd4e5da5Sopenharmony_ci  EXPECT_EQ(*it, spv::Capability::Shader);
618fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.contains(spv::Capability::Shader));
619fd4e5da5Sopenharmony_ci}
620fd4e5da5Sopenharmony_ci
621fd4e5da5Sopenharmony_ciTEST(CapabilitySet, IteratorCanBeCopied) {
622fd4e5da5Sopenharmony_ci  CapabilitySet set;
623fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Matrix);
624fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Shader);
625fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Geometry);
626fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Float64);
627fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Float16);
628fd4e5da5Sopenharmony_ci
629fd4e5da5Sopenharmony_ci  auto a = set.begin();
630fd4e5da5Sopenharmony_ci  ++a;
631fd4e5da5Sopenharmony_ci  auto b = a;
632fd4e5da5Sopenharmony_ci
633fd4e5da5Sopenharmony_ci  EXPECT_EQ(*b, *a);
634fd4e5da5Sopenharmony_ci  ++b;
635fd4e5da5Sopenharmony_ci  EXPECT_NE(*b, *a);
636fd4e5da5Sopenharmony_ci
637fd4e5da5Sopenharmony_ci  ++a;
638fd4e5da5Sopenharmony_ci  EXPECT_EQ(*b, *a);
639fd4e5da5Sopenharmony_ci
640fd4e5da5Sopenharmony_ci  ++a;
641fd4e5da5Sopenharmony_ci  EXPECT_NE(*b, *a);
642fd4e5da5Sopenharmony_ci}
643fd4e5da5Sopenharmony_ci
644fd4e5da5Sopenharmony_ciTEST(CapabilitySet, IteratorBeginToEndPostfix) {
645fd4e5da5Sopenharmony_ci  auto orderedValues = enumerateValuesFromToWithStep(0, 100, /* step= */ 1);
646fd4e5da5Sopenharmony_ci  auto set = createSetUnorderedInsertion(orderedValues);
647fd4e5da5Sopenharmony_ci
648fd4e5da5Sopenharmony_ci  size_t index = 0;
649fd4e5da5Sopenharmony_ci  for (auto it = set.cbegin(); it != set.cend(); it++, index++) {
650fd4e5da5Sopenharmony_ci    EXPECT_EQ(*it, orderedValues[index]);
651fd4e5da5Sopenharmony_ci  }
652fd4e5da5Sopenharmony_ci}
653fd4e5da5Sopenharmony_ci
654fd4e5da5Sopenharmony_ciTEST(CapabilitySet, IteratorBeginToEndPrefix) {
655fd4e5da5Sopenharmony_ci  auto orderedValues = enumerateValuesFromToWithStep(0, 100, /* step= */ 1);
656fd4e5da5Sopenharmony_ci  auto set = createSetUnorderedInsertion(orderedValues);
657fd4e5da5Sopenharmony_ci
658fd4e5da5Sopenharmony_ci  size_t index = 0;
659fd4e5da5Sopenharmony_ci  for (auto it = set.cbegin(); it != set.cend(); ++it, index++) {
660fd4e5da5Sopenharmony_ci    EXPECT_EQ(*it, orderedValues[index]);
661fd4e5da5Sopenharmony_ci  }
662fd4e5da5Sopenharmony_ci}
663fd4e5da5Sopenharmony_ci
664fd4e5da5Sopenharmony_ciTEST(CapabilitySet, IteratorBeginToEndPrefixStep) {
665fd4e5da5Sopenharmony_ci  auto orderedValues = enumerateValuesFromToWithStep(0, 100, /* step= */ 8);
666fd4e5da5Sopenharmony_ci  auto set = createSetUnorderedInsertion(orderedValues);
667fd4e5da5Sopenharmony_ci
668fd4e5da5Sopenharmony_ci  size_t index = 0;
669fd4e5da5Sopenharmony_ci  for (auto it = set.cbegin(); it != set.cend(); ++it, index++) {
670fd4e5da5Sopenharmony_ci    ASSERT_EQ(*it, orderedValues[index]);
671fd4e5da5Sopenharmony_ci  }
672fd4e5da5Sopenharmony_ci}
673fd4e5da5Sopenharmony_ci
674fd4e5da5Sopenharmony_ciTEST(CapabilitySet, IteratorBeginOnEmpty) {
675fd4e5da5Sopenharmony_ci  CapabilitySet set;
676fd4e5da5Sopenharmony_ci
677fd4e5da5Sopenharmony_ci  auto begin = set.begin();
678fd4e5da5Sopenharmony_ci  auto end = set.end();
679fd4e5da5Sopenharmony_ci  ASSERT_EQ(begin, end);
680fd4e5da5Sopenharmony_ci}
681fd4e5da5Sopenharmony_ci
682fd4e5da5Sopenharmony_ciTEST(CapabilitySet, IteratorBeginOnSingleNonZeroValue) {
683fd4e5da5Sopenharmony_ci  CapabilitySet set;
684fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Shader);
685fd4e5da5Sopenharmony_ci
686fd4e5da5Sopenharmony_ci  auto begin = set.begin();
687fd4e5da5Sopenharmony_ci  auto end = set.end();
688fd4e5da5Sopenharmony_ci
689fd4e5da5Sopenharmony_ci  ASSERT_NE(begin, end);
690fd4e5da5Sopenharmony_ci  ASSERT_EQ(*begin, spv::Capability::Shader);
691fd4e5da5Sopenharmony_ci}
692fd4e5da5Sopenharmony_ci
693fd4e5da5Sopenharmony_ciTEST(CapabilitySet, IteratorForLoopNonZeroValue) {
694fd4e5da5Sopenharmony_ci  CapabilitySet set;
695fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Shader);
696fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Tessellation);
697fd4e5da5Sopenharmony_ci
698fd4e5da5Sopenharmony_ci  auto begin = set.begin();
699fd4e5da5Sopenharmony_ci  auto end = set.end();
700fd4e5da5Sopenharmony_ci
701fd4e5da5Sopenharmony_ci  ASSERT_NE(begin, end);
702fd4e5da5Sopenharmony_ci  ASSERT_EQ(*begin, spv::Capability::Shader);
703fd4e5da5Sopenharmony_ci
704fd4e5da5Sopenharmony_ci  begin++;
705fd4e5da5Sopenharmony_ci  ASSERT_NE(begin, end);
706fd4e5da5Sopenharmony_ci  ASSERT_EQ(*begin, spv::Capability::Tessellation);
707fd4e5da5Sopenharmony_ci
708fd4e5da5Sopenharmony_ci  begin++;
709fd4e5da5Sopenharmony_ci  ASSERT_EQ(begin, end);
710fd4e5da5Sopenharmony_ci}
711fd4e5da5Sopenharmony_ci
712fd4e5da5Sopenharmony_ciTEST(CapabilitySet, IteratorPastEnd) {
713fd4e5da5Sopenharmony_ci  CapabilitySet set;
714fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Shader);
715fd4e5da5Sopenharmony_ci
716fd4e5da5Sopenharmony_ci  auto begin = set.begin();
717fd4e5da5Sopenharmony_ci  auto end = set.end();
718fd4e5da5Sopenharmony_ci
719fd4e5da5Sopenharmony_ci  ASSERT_NE(begin, end);
720fd4e5da5Sopenharmony_ci  ASSERT_EQ(*begin, spv::Capability::Shader);
721fd4e5da5Sopenharmony_ci
722fd4e5da5Sopenharmony_ci  begin++;
723fd4e5da5Sopenharmony_ci  ASSERT_EQ(begin, end);
724fd4e5da5Sopenharmony_ci
725fd4e5da5Sopenharmony_ci  begin++;
726fd4e5da5Sopenharmony_ci  ASSERT_EQ(begin, end);
727fd4e5da5Sopenharmony_ci}
728fd4e5da5Sopenharmony_ci
729fd4e5da5Sopenharmony_ciTEST(CapabilitySet, CompatibleWithSTLFind) {
730fd4e5da5Sopenharmony_ci  CapabilitySet set;
731fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Matrix);
732fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Shader);
733fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Geometry);
734fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Tessellation);
735fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Addresses);
736fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Linkage);
737fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Kernel);
738fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Vector16);
739fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Float16Buffer);
740fd4e5da5Sopenharmony_ci  set.insert(spv::Capability::Float64);
741fd4e5da5Sopenharmony_ci
742fd4e5da5Sopenharmony_ci  {
743fd4e5da5Sopenharmony_ci    auto it = std::find(set.cbegin(), set.cend(), spv::Capability::Vector16);
744fd4e5da5Sopenharmony_ci    ASSERT_NE(it, set.end());
745fd4e5da5Sopenharmony_ci    ASSERT_EQ(*it, spv::Capability::Vector16);
746fd4e5da5Sopenharmony_ci  }
747fd4e5da5Sopenharmony_ci
748fd4e5da5Sopenharmony_ci  {
749fd4e5da5Sopenharmony_ci    auto it = std::find(set.cbegin(), set.cend(), spv::Capability::Float16);
750fd4e5da5Sopenharmony_ci    ASSERT_EQ(it, set.end());
751fd4e5da5Sopenharmony_ci  }
752fd4e5da5Sopenharmony_ci}
753fd4e5da5Sopenharmony_ci
754fd4e5da5Sopenharmony_ciTEST(CapabilitySet, CompatibleWithSTLForEach) {
755fd4e5da5Sopenharmony_ci  auto orderedValues = enumerateValuesFromToWithStep(0, 100, /* step= */ 15);
756fd4e5da5Sopenharmony_ci  auto set = createSetUnorderedInsertion(orderedValues);
757fd4e5da5Sopenharmony_ci
758fd4e5da5Sopenharmony_ci  size_t index = 0;
759fd4e5da5Sopenharmony_ci  std::for_each(set.cbegin(), set.cend(), [&](auto item) {
760fd4e5da5Sopenharmony_ci    ASSERT_EQ(item, orderedValues[index]);
761fd4e5da5Sopenharmony_ci    index++;
762fd4e5da5Sopenharmony_ci  });
763fd4e5da5Sopenharmony_ci}
764fd4e5da5Sopenharmony_ci
765fd4e5da5Sopenharmony_ciTEST(CapabilitySet, InitializerListEmpty) {
766fd4e5da5Sopenharmony_ci  CapabilitySet s{};
767fd4e5da5Sopenharmony_ci  for (uint32_t i = 0; i < 1000; i++) {
768fd4e5da5Sopenharmony_ci    EXPECT_FALSE(s.contains(static_cast<spv::Capability>(i)));
769fd4e5da5Sopenharmony_ci  }
770fd4e5da5Sopenharmony_ci}
771fd4e5da5Sopenharmony_ci
772fd4e5da5Sopenharmony_ciTEST(CapabilitySet, LargeSetHasInsertedElements) {
773fd4e5da5Sopenharmony_ci  CapabilitySet set;
774fd4e5da5Sopenharmony_ci  for (auto c : kCapabilities) {
775fd4e5da5Sopenharmony_ci    EXPECT_FALSE(set.contains(c));
776fd4e5da5Sopenharmony_ci  }
777fd4e5da5Sopenharmony_ci
778fd4e5da5Sopenharmony_ci  for (auto c : kCapabilities) {
779fd4e5da5Sopenharmony_ci    set.insert(c);
780fd4e5da5Sopenharmony_ci    EXPECT_TRUE(set.contains(c));
781fd4e5da5Sopenharmony_ci  }
782fd4e5da5Sopenharmony_ci
783fd4e5da5Sopenharmony_ci  for (auto c : kCapabilities) {
784fd4e5da5Sopenharmony_ci    EXPECT_TRUE(set.contains(c));
785fd4e5da5Sopenharmony_ci  }
786fd4e5da5Sopenharmony_ci}
787fd4e5da5Sopenharmony_ci
788fd4e5da5Sopenharmony_ciTEST(CapabilitySet, LargeSetHasUnsortedInsertedElements) {
789fd4e5da5Sopenharmony_ci  std::vector shuffledCapabilities(kCapabilities.cbegin(),
790fd4e5da5Sopenharmony_ci                                   kCapabilities.cend());
791fd4e5da5Sopenharmony_ci  std::mt19937 rng(0);
792fd4e5da5Sopenharmony_ci  std::shuffle(shuffledCapabilities.begin(), shuffledCapabilities.end(), rng);
793fd4e5da5Sopenharmony_ci  CapabilitySet set;
794fd4e5da5Sopenharmony_ci  for (auto c : shuffledCapabilities) {
795fd4e5da5Sopenharmony_ci    EXPECT_FALSE(set.contains(c));
796fd4e5da5Sopenharmony_ci  }
797fd4e5da5Sopenharmony_ci
798fd4e5da5Sopenharmony_ci  for (auto c : shuffledCapabilities) {
799fd4e5da5Sopenharmony_ci    set.insert(c);
800fd4e5da5Sopenharmony_ci    EXPECT_TRUE(set.contains(c));
801fd4e5da5Sopenharmony_ci  }
802fd4e5da5Sopenharmony_ci
803fd4e5da5Sopenharmony_ci  for (auto c : shuffledCapabilities) {
804fd4e5da5Sopenharmony_ci    EXPECT_TRUE(set.contains(c));
805fd4e5da5Sopenharmony_ci  }
806fd4e5da5Sopenharmony_ci}
807fd4e5da5Sopenharmony_ci
808fd4e5da5Sopenharmony_ciTEST(CapabilitySet, LargeSetHasUnsortedRemovedElement) {
809fd4e5da5Sopenharmony_ci  std::vector shuffledCapabilities(kCapabilities.cbegin(),
810fd4e5da5Sopenharmony_ci                                   kCapabilities.cend());
811fd4e5da5Sopenharmony_ci  std::mt19937 rng(0);
812fd4e5da5Sopenharmony_ci  std::shuffle(shuffledCapabilities.begin(), shuffledCapabilities.end(), rng);
813fd4e5da5Sopenharmony_ci  CapabilitySet set;
814fd4e5da5Sopenharmony_ci  for (auto c : shuffledCapabilities) {
815fd4e5da5Sopenharmony_ci    set.insert(c);
816fd4e5da5Sopenharmony_ci    EXPECT_TRUE(set.contains(c));
817fd4e5da5Sopenharmony_ci  }
818fd4e5da5Sopenharmony_ci
819fd4e5da5Sopenharmony_ci  for (auto c : kCapabilities) {
820fd4e5da5Sopenharmony_ci    set.erase(c);
821fd4e5da5Sopenharmony_ci  }
822fd4e5da5Sopenharmony_ci
823fd4e5da5Sopenharmony_ci  for (auto c : shuffledCapabilities) {
824fd4e5da5Sopenharmony_ci    EXPECT_FALSE(set.contains(c));
825fd4e5da5Sopenharmony_ci  }
826fd4e5da5Sopenharmony_ci}
827fd4e5da5Sopenharmony_ci
828fd4e5da5Sopenharmony_cistruct ForEachCase {
829fd4e5da5Sopenharmony_ci  CapabilitySet capabilities;
830fd4e5da5Sopenharmony_ci  std::vector<spv::Capability> expected;
831fd4e5da5Sopenharmony_ci};
832fd4e5da5Sopenharmony_ci
833fd4e5da5Sopenharmony_ciusing CapabilitySetForEachTest = ::testing::TestWithParam<ForEachCase>;
834fd4e5da5Sopenharmony_ci
835fd4e5da5Sopenharmony_ciTEST_P(CapabilitySetForEachTest, CallsAsExpected) {
836fd4e5da5Sopenharmony_ci  EXPECT_THAT(ElementsIn(GetParam().capabilities), Eq(GetParam().expected));
837fd4e5da5Sopenharmony_ci}
838fd4e5da5Sopenharmony_ci
839fd4e5da5Sopenharmony_ciTEST_P(CapabilitySetForEachTest, CopyConstructor) {
840fd4e5da5Sopenharmony_ci  CapabilitySet copy(GetParam().capabilities);
841fd4e5da5Sopenharmony_ci  EXPECT_THAT(ElementsIn(copy), Eq(GetParam().expected));
842fd4e5da5Sopenharmony_ci}
843fd4e5da5Sopenharmony_ci
844fd4e5da5Sopenharmony_ciTEST_P(CapabilitySetForEachTest, MoveConstructor) {
845fd4e5da5Sopenharmony_ci  // We need a writable copy to move from.
846fd4e5da5Sopenharmony_ci  CapabilitySet copy(GetParam().capabilities);
847fd4e5da5Sopenharmony_ci  CapabilitySet moved(std::move(copy));
848fd4e5da5Sopenharmony_ci  EXPECT_THAT(ElementsIn(moved), Eq(GetParam().expected));
849fd4e5da5Sopenharmony_ci
850fd4e5da5Sopenharmony_ci  // The moved-from set is empty.
851fd4e5da5Sopenharmony_ci  EXPECT_THAT(ElementsIn(copy), Eq(std::vector<spv::Capability>{}));
852fd4e5da5Sopenharmony_ci}
853fd4e5da5Sopenharmony_ci
854fd4e5da5Sopenharmony_ciTEST_P(CapabilitySetForEachTest, OperatorEquals) {
855fd4e5da5Sopenharmony_ci  CapabilitySet assigned = GetParam().capabilities;
856fd4e5da5Sopenharmony_ci  EXPECT_THAT(ElementsIn(assigned), Eq(GetParam().expected));
857fd4e5da5Sopenharmony_ci}
858fd4e5da5Sopenharmony_ci
859fd4e5da5Sopenharmony_ciTEST_P(CapabilitySetForEachTest, OperatorEqualsSelfAssign) {
860fd4e5da5Sopenharmony_ci  CapabilitySet assigned{GetParam().capabilities};
861fd4e5da5Sopenharmony_ci  assigned = assigned;
862fd4e5da5Sopenharmony_ci  EXPECT_THAT(ElementsIn(assigned), Eq(GetParam().expected));
863fd4e5da5Sopenharmony_ci}
864fd4e5da5Sopenharmony_ci
865fd4e5da5Sopenharmony_ciINSTANTIATE_TEST_SUITE_P(
866fd4e5da5Sopenharmony_ci    Samples, CapabilitySetForEachTest,
867fd4e5da5Sopenharmony_ci    ValuesIn(std::vector<ForEachCase>{
868fd4e5da5Sopenharmony_ci        {{}, {}},
869fd4e5da5Sopenharmony_ci        {{spv::Capability::Matrix}, {spv::Capability::Matrix}},
870fd4e5da5Sopenharmony_ci        {{spv::Capability::Kernel, spv::Capability::Shader},
871fd4e5da5Sopenharmony_ci         {spv::Capability::Shader, spv::Capability::Kernel}},
872fd4e5da5Sopenharmony_ci        {{static_cast<spv::Capability>(999)},
873fd4e5da5Sopenharmony_ci         {static_cast<spv::Capability>(999)}},
874fd4e5da5Sopenharmony_ci        {{static_cast<spv::Capability>(0x7fffffff)},
875fd4e5da5Sopenharmony_ci         {static_cast<spv::Capability>(0x7fffffff)}},
876fd4e5da5Sopenharmony_ci        // Mixture and out of order
877fd4e5da5Sopenharmony_ci        {{static_cast<spv::Capability>(0x7fffffff),
878fd4e5da5Sopenharmony_ci          static_cast<spv::Capability>(100), spv::Capability::Shader,
879fd4e5da5Sopenharmony_ci          spv::Capability::Matrix},
880fd4e5da5Sopenharmony_ci         {spv::Capability::Matrix, spv::Capability::Shader,
881fd4e5da5Sopenharmony_ci          static_cast<spv::Capability>(100),
882fd4e5da5Sopenharmony_ci          static_cast<spv::Capability>(0x7fffffff)}},
883fd4e5da5Sopenharmony_ci    }));
884fd4e5da5Sopenharmony_ci
885fd4e5da5Sopenharmony_ciusing BoundaryTestWithParam = ::testing::TestWithParam<spv::Capability>;
886fd4e5da5Sopenharmony_ci
887fd4e5da5Sopenharmony_ciTEST_P(BoundaryTestWithParam, InsertedContains) {
888fd4e5da5Sopenharmony_ci  CapabilitySet set;
889fd4e5da5Sopenharmony_ci  set.insert(GetParam());
890fd4e5da5Sopenharmony_ci  EXPECT_TRUE(set.contains(GetParam()));
891fd4e5da5Sopenharmony_ci}
892fd4e5da5Sopenharmony_ci
893fd4e5da5Sopenharmony_ciINSTANTIATE_TEST_SUITE_P(
894fd4e5da5Sopenharmony_ci    Samples, BoundaryTestWithParam,
895fd4e5da5Sopenharmony_ci    Values(static_cast<spv::Capability>(0), static_cast<spv::Capability>(63),
896fd4e5da5Sopenharmony_ci           static_cast<spv::Capability>(64), static_cast<spv::Capability>(65),
897fd4e5da5Sopenharmony_ci           static_cast<spv::Capability>(127), static_cast<spv::Capability>(128),
898fd4e5da5Sopenharmony_ci           static_cast<spv::Capability>(129)));
899fd4e5da5Sopenharmony_ci
900fd4e5da5Sopenharmony_ci}  // namespace
901fd4e5da5Sopenharmony_ci}  // namespace spvtools
902