Victor Boivie | f53127a | 2021-03-30 19:17:19 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | #ifndef NET_DCSCTP_TESTING_TESTING_MACROS_H_ |
| 11 | #define NET_DCSCTP_TESTING_TESTING_MACROS_H_ |
| 12 | |
| 13 | #include <utility> |
| 14 | |
| 15 | namespace dcsctp { |
| 16 | |
| 17 | #define DCSCTP_CONCAT_INNER_(x, y) x##y |
| 18 | #define DCSCTP_CONCAT_(x, y) DCSCTP_CONCAT_INNER_(x, y) |
| 19 | |
| 20 | // Similar to ASSERT_OK_AND_ASSIGN, this works with an absl::optional<> instead |
| 21 | // of an absl::StatusOr<>. |
| 22 | #define ASSERT_HAS_VALUE_AND_ASSIGN(lhs, rexpr) \ |
| 23 | auto DCSCTP_CONCAT_(tmp_opt_val__, __LINE__) = rexpr; \ |
| 24 | ASSERT_TRUE(DCSCTP_CONCAT_(tmp_opt_val__, __LINE__).has_value()); \ |
| 25 | lhs = *std::move(DCSCTP_CONCAT_(tmp_opt_val__, __LINE__)); |
| 26 | |
| 27 | } // namespace dcsctp |
| 28 | |
| 29 | #endif // NET_DCSCTP_TESTING_TESTING_MACROS_H_ |