[libc++][ranges][NFC] Merge join_with_views [[nodiscard]] tests (#175734)
This just merges all tests in a single `nodiscard.verify.cpp` as is the common practice.
This commit is contained in:
parent
309ca6dd47
commit
f7b943e4ed
@ -0,0 +1,99 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// Test that functions are marked [[nodiscard]].
|
||||
|
||||
#include <array>
|
||||
#include <ranges>
|
||||
#include <utility>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "test_range.h"
|
||||
|
||||
void test() {
|
||||
int range[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
|
||||
int pattern[2] = {-1, -1};
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
|
||||
// clang-format off
|
||||
view.base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::as_const(view).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::move(std::as_const(view)).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::move(view).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
view.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::as_const(view).begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
view.end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::as_const(view).end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void test_iterator() {
|
||||
char range[3][2] = {{'x', 'x'}, {'y', 'y'}, {'z', 'z'}};
|
||||
char pattern[2] = {',', ' '};
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
|
||||
// clang-format off
|
||||
*view.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
*std::as_const(view).begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
(view.begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(std::as_const(view).begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(view.begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(std::as_const(view).begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
iter_move(view.begin()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
iter_move(std::as_const(view).begin()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void test_sentinel() {
|
||||
std::array<test_range<cpp20_input_iterator>, 0> range;
|
||||
std::array<int, 0> pattern;
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
static_assert(!std::ranges::common_range<decltype(view)>);
|
||||
|
||||
// clang-format off
|
||||
(view.begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(std::as_const(view).begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(view.begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(std::as_const(view).begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void test_overview() {
|
||||
int range[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
|
||||
int pattern_base[2] = {-1, -1};
|
||||
auto pattern = std::views::all(pattern_base);
|
||||
|
||||
// clang-format off
|
||||
std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::views::join_with(range, pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
range | std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::views::reverse | std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
|
||||
std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::views::join_with(range, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
range | std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::views::reverse | std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// <ranges>
|
||||
|
||||
// Test the libc++ extension that std::ranges::join_with_view::iterator<Const>::operator* is marked as [[nodiscard]].
|
||||
|
||||
#include <ranges>
|
||||
#include <utility>
|
||||
|
||||
void test() {
|
||||
char range[3][2] = {{'x', 'x'}, {'y', 'y'}, {'z', 'z'}};
|
||||
char pattern[2] = {',', ' '};
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
|
||||
// clang-format off
|
||||
*view.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
*std::as_const(view).begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// <ranges>
|
||||
|
||||
// Test the libc++ extension that std::ranges::join_with_view::iterator<Const>::operator== is marked as [[nodiscard]].
|
||||
|
||||
#include <ranges>
|
||||
#include <utility>
|
||||
|
||||
void test() {
|
||||
char16_t range[3][1] = {{u'x'}, {u'y'}, {u'z'}};
|
||||
char16_t pattern[1] = {u'-'};
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
|
||||
// clang-format off
|
||||
(view.begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(std::as_const(view).begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(view.begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(std::as_const(view).begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// <ranges>
|
||||
|
||||
// Test the libc++ extension that std::ranges::join_with_view::iterator<Const>::iter_move is marked as [[nodiscard]].
|
||||
|
||||
#include <ranges>
|
||||
#include <utility>
|
||||
|
||||
void test() {
|
||||
long range[2][1] = {{0L}, {2L}};
|
||||
long pattern[1] = {1L};
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
|
||||
// clang-format off
|
||||
iter_move(view.begin()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
iter_move(std::as_const(view).begin()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// <ranges>
|
||||
|
||||
// Test the libc++ extension that std::views::join_with is marked as [[nodiscard]].
|
||||
|
||||
#include <ranges>
|
||||
|
||||
void test() {
|
||||
int range[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
|
||||
int pattern_base[2] = {-1, -1};
|
||||
auto pattern = std::views::all(pattern_base);
|
||||
|
||||
// clang-format off
|
||||
std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::views::join_with(range, pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
range | std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::views::reverse | std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
|
||||
std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::views::join_with(range, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
range | std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::views::reverse | std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// <ranges>
|
||||
|
||||
// Test the libc++ extension that std::ranges::join_with_view::sentinel<Const>::operator== is marked as [[nodiscard]].
|
||||
|
||||
#include <array>
|
||||
#include <ranges>
|
||||
#include <utility>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "test_range.h"
|
||||
|
||||
void test() {
|
||||
std::array<test_range<cpp20_input_iterator>, 0> range;
|
||||
std::array<int, 0> pattern;
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
static_assert(!std::ranges::common_range<decltype(view)>);
|
||||
|
||||
// clang-format off
|
||||
(view.begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(std::as_const(view).begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(view.begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
(std::as_const(view).begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// <ranges>
|
||||
|
||||
// Test the libc++ extension that std::ranges::join_with_view::base is marked as [[nodiscard]].
|
||||
|
||||
#include <ranges>
|
||||
#include <utility>
|
||||
|
||||
void test() {
|
||||
int range[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
|
||||
int pattern[2] = {-1, -1};
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
|
||||
// clang-format off
|
||||
view.base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::as_const(view).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::move(std::as_const(view)).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::move(view).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// <ranges>
|
||||
|
||||
// Test the libc++ extension that std::ranges::join_with_view::begin is marked as [[nodiscard]].
|
||||
|
||||
#include <ranges>
|
||||
#include <utility>
|
||||
|
||||
void test() {
|
||||
int range[3][2] = {{1, 3}, {4, 6}, {7, 9}};
|
||||
int pattern[1] = {-2};
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
|
||||
// clang-format off
|
||||
view.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::as_const(view).begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: std-at-least-c++23
|
||||
|
||||
// <ranges>
|
||||
|
||||
// Test the libc++ extension that std::ranges::join_with_view::end is marked as [[nodiscard]].
|
||||
|
||||
#include <ranges>
|
||||
#include <utility>
|
||||
|
||||
void test() {
|
||||
int range[3][2] = {{1, 2}, {4, 5}, {7, 8}};
|
||||
int pattern[1] = {-3};
|
||||
|
||||
std::ranges::join_with_view view(range, pattern);
|
||||
|
||||
// clang-format off
|
||||
view.end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
std::as_const(view).end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
// clang-format on
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user