Skip to content

Commit 0dec6bc

Browse files
committed
Move urSamplerGetInfo success test from a switch to individual tests.
1 parent 1918293 commit 0dec6bc

File tree

1 file changed

+62
-52
lines changed

1 file changed

+62
-52
lines changed

test/conformance/sampler/urSamplerGetInfo.cpp

Lines changed: 62 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,70 @@
55

66
#include <uur/fixtures.h>
77

8-
using urSamplerGetInfoTestWithParam =
9-
uur::urSamplerTestWithParam<ur_sampler_info_t>;
10-
UUR_TEST_SUITE_P(urSamplerGetInfoTestWithParam,
11-
::testing::Values(UR_SAMPLER_INFO_REFERENCE_COUNT,
12-
UR_SAMPLER_INFO_CONTEXT,
13-
UR_SAMPLER_INFO_NORMALIZED_COORDS,
14-
UR_SAMPLER_INFO_ADDRESSING_MODE,
15-
UR_SAMPLER_INFO_FILTER_MODE),
16-
uur::deviceTestWithParamPrinter<ur_sampler_info_t>);
17-
18-
TEST_P(urSamplerGetInfoTestWithParam, Success) {
8+
using urSamplerGetInfoTest = uur::urSamplerTest;
9+
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerGetInfoTest);
10+
11+
TEST_P(urSamplerGetInfoTest, SuccessReferenceCount) {
1912
size_t size = 0;
20-
ur_sampler_info_t info = getParam();
21-
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
22-
urSamplerGetInfo(sampler, info, 0, nullptr, &size), info);
23-
ASSERT_NE(size, 0);
24-
std::vector<uint8_t> infoData(size);
13+
auto infoType = UR_SAMPLER_INFO_REFERENCE_COUNT;
2514
ASSERT_SUCCESS(
26-
urSamplerGetInfo(sampler, info, size, infoData.data(), nullptr));
27-
28-
switch (info) {
29-
case UR_SAMPLER_INFO_REFERENCE_COUNT: {
30-
auto *value = reinterpret_cast<uint32_t *>(infoData.data());
31-
ASSERT_TRUE(*value > 0);
32-
break;
33-
}
34-
case UR_SAMPLER_INFO_CONTEXT: {
35-
auto *value = reinterpret_cast<ur_context_handle_t *>(infoData.data());
36-
ASSERT_EQ(*value, this->context);
37-
break;
38-
}
39-
case UR_SAMPLER_INFO_NORMALIZED_COORDS: {
40-
auto *value = reinterpret_cast<ur_bool_t *>(infoData.data());
41-
ASSERT_EQ(*value, sampler_desc.normalizedCoords);
42-
break;
43-
}
44-
case UR_SAMPLER_INFO_ADDRESSING_MODE: {
45-
auto *value =
46-
reinterpret_cast<ur_sampler_addressing_mode_t *>(infoData.data());
47-
ASSERT_EQ(*value, sampler_desc.addressingMode);
48-
break;
49-
}
50-
case UR_SAMPLER_INFO_FILTER_MODE: {
51-
auto *value =
52-
reinterpret_cast<ur_sampler_filter_mode_t *>(infoData.data());
53-
ASSERT_EQ(*value, sampler_desc.filterMode);
54-
}
55-
default:
56-
break;
57-
}
15+
urSamplerGetInfo(sampler, infoType, 0, nullptr, &size));
16+
ASSERT_EQ(sizeof(uint32_t), size);
17+
18+
uint32_t returned_reference_count = 0;
19+
ASSERT_SUCCESS(urSamplerGetInfo(sampler, infoType, size, &returned_reference_count, nullptr));
20+
21+
ASSERT_GT(returned_reference_count, 0U);
5822
}
5923

60-
using urSamplerGetInfoTest = uur::urSamplerTest;
61-
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urSamplerGetInfoTest);
24+
TEST_P(urSamplerGetInfoTest, SuccessContext) {
25+
size_t size = 0;
26+
auto infoType = UR_SAMPLER_INFO_CONTEXT;
27+
ASSERT_SUCCESS(
28+
urSamplerGetInfo(sampler, infoType, 0, nullptr, &size));
29+
ASSERT_EQ(sizeof(ur_context_handle_t), size);
30+
31+
ur_context_handle_t returned_context = nullptr;
32+
ASSERT_SUCCESS(urSamplerGetInfo(sampler, infoType, size, &returned_context, nullptr));
33+
34+
ASSERT_EQ(returned_context, context);
35+
}
36+
37+
TEST_P(urSamplerGetInfoTest, SuccessNormalizedCoords) {
38+
size_t size = 0;
39+
auto infoType = UR_SAMPLER_INFO_NORMALIZED_COORDS;
40+
ASSERT_SUCCESS(
41+
urSamplerGetInfo(sampler, infoType, 0, nullptr, &size));
42+
ASSERT_EQ(sizeof(ur_bool_t), size);
43+
}
44+
45+
TEST_P(urSamplerGetInfoTest, SuccessAddressingMode) {
46+
size_t size = 0;
47+
auto infoType = UR_SAMPLER_INFO_ADDRESSING_MODE;
48+
ASSERT_SUCCESS(
49+
urSamplerGetInfo(sampler, infoType, 0, nullptr, &size));
50+
ASSERT_EQ(sizeof(ur_sampler_addressing_mode_t), size);
51+
52+
ur_sampler_addressing_mode_t returned_mode = UR_SAMPLER_ADDRESSING_MODE_FORCE_UINT32;
53+
ASSERT_SUCCESS(urSamplerGetInfo(sampler, infoType, size, &returned_mode, nullptr));
54+
55+
ASSERT_GE(returned_mode, UR_SAMPLER_ADDRESSING_MODE_NONE);
56+
ASSERT_LT(returned_mode, UR_SAMPLER_ADDRESSING_MODE_FORCE_UINT32);
57+
}
58+
59+
TEST_P(urSamplerGetInfoTest, SuccessFilterMode) {
60+
size_t size = 0;
61+
auto infoType = UR_SAMPLER_INFO_FILTER_MODE;
62+
ASSERT_SUCCESS(
63+
urSamplerGetInfo(sampler, infoType, 0, nullptr, &size));
64+
ASSERT_EQ(sizeof(ur_sampler_filter_mode_t), size);
65+
66+
ur_sampler_filter_mode_t returned_mode = UR_SAMPLER_FILTER_MODE_FORCE_UINT32;
67+
ASSERT_SUCCESS(urSamplerGetInfo(sampler, infoType, size, &returned_mode, nullptr));
68+
69+
ASSERT_GE(returned_mode, UR_SAMPLER_FILTER_MODE_NEAREST);
70+
ASSERT_LT(returned_mode, UR_SAMPLER_FILTER_MODE_FORCE_UINT32);
71+
}
6272

6373
TEST_P(urSamplerGetInfoTest, InvalidNullHandleSampler) {
6474
uint32_t refcount = 0;
@@ -88,14 +98,14 @@ TEST_P(urSamplerGetInfoTest, InvalidNullPointerPropValue) {
8898
}
8999

90100
TEST_P(urSamplerGetInfoTest, InvalidSizePropSizeZero) {
91-
ur_sampler_addressing_mode_t mode;
101+
ur_sampler_addressing_mode_t mode = UR_SAMPLER_ADDRESSING_MODE_NONE;
92102
ASSERT_EQ_RESULT(urSamplerGetInfo(sampler, UR_SAMPLER_INFO_ADDRESSING_MODE,
93103
0, &mode, nullptr),
94104
UR_RESULT_ERROR_INVALID_SIZE);
95105
}
96106

97107
TEST_P(urSamplerGetInfoTest, InvalidSizePropSizeSmall) {
98-
ur_sampler_addressing_mode_t mode;
108+
ur_sampler_addressing_mode_t mode = UR_SAMPLER_ADDRESSING_MODE_NONE;
99109
ASSERT_EQ_RESULT(urSamplerGetInfo(sampler, UR_SAMPLER_INFO_ADDRESSING_MODE,
100110
sizeof(mode) - 1, &mode, nullptr),
101111
UR_RESULT_ERROR_INVALID_SIZE);

0 commit comments

Comments
 (0)