Skip to content

Commit 15351cc

Browse files
add queryability tests for stdexec::env (#1655)
adds tests of the `stdexec::env` utility to check for ability to SFINAE-detect supported and unsupported queries. Co-authored-by: Eric Niebler <[email protected]>
1 parent 14798e8 commit 15351cc

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ set(stdexec_test_sources
6161
stdexec/algos/other/test_execute.cpp
6262
stdexec/detail/test_completion_signatures.cpp
6363
stdexec/detail/test_utility.cpp
64+
stdexec/queries/test_env.cpp
6465
stdexec/queries/test_get_forward_progress_guarantee.cpp
6566
stdexec/queries/test_forwarding_queries.cpp
6667
)

test/stdexec/queries/test_env.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* Copyright (c) 2025 Robert Leahy. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
*
6+
* Licensed under the Apache License, Version 2.0 with LLVM Exceptions (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://llvm.org/LICENSE.txt
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <catch2/catch.hpp>
20+
#include <stdexec/execution.hpp>
21+
22+
namespace {
23+
24+
template <typename T>
25+
concept can_get_domain = requires(const T& t) { t.query(::stdexec::get_domain); };
26+
27+
namespace zero {
28+
29+
using env = ::stdexec::env<>;
30+
static_assert(std::is_same_v<::stdexec::never_stop_token, ::stdexec::stop_token_of_t<env>>);
31+
static_assert(!can_get_domain<env>);
32+
33+
} // namespace zero
34+
35+
namespace one {
36+
using env = ::stdexec::env<::stdexec::env<>>;
37+
static_assert(std::is_same_v<::stdexec::never_stop_token, ::stdexec::stop_token_of_t<env>>);
38+
static_assert(!can_get_domain<env>);
39+
} // namespace one
40+
41+
namespace two {
42+
using env = ::stdexec::env<::stdexec::env<>, ::stdexec::env<>>;
43+
static_assert(std::is_same_v<::stdexec::never_stop_token, ::stdexec::stop_token_of_t<env>>);
44+
static_assert(!can_get_domain<env>);
45+
} // namespace two
46+
47+
namespace three {
48+
using env = ::stdexec::env<::stdexec::env<>, ::stdexec::env<>, ::stdexec::env<>>;
49+
static_assert(std::is_same_v<::stdexec::never_stop_token, ::stdexec::stop_token_of_t<env>>);
50+
static_assert(!can_get_domain<env>);
51+
} // namespace three
52+
} // namespace

0 commit comments

Comments
 (0)