test_forward_like.cpp
Go to the documentation of this file.
1 // Copyright 2023-2024 Ekumen, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <gtest/gtest.h>
16 
17 #include <type_traits>
18 
20 
21 namespace {
22 
23 struct Object {};
24 
25 TEST(ForwardLike, Rvalue) {
26  static_assert(std::is_same_v<decltype(beluga::forward_like<float&>(Object{})), Object&>);
27  static_assert(std::is_same_v<decltype(beluga::forward_like<const float&>(Object{})), const Object&>);
28  static_assert(std::is_same_v<decltype(beluga::forward_like<float&&>(Object{})), Object&&>);
29  static_assert(std::is_same_v<decltype(beluga::forward_like<const float&&>(Object{})), const Object&&>);
30 }
31 
32 TEST(ForwardLike, MutableLvalue) {
33  auto object = Object{};
34  static_assert(std::is_same_v<decltype(beluga::forward_like<float&>(object)), Object&>);
35  static_assert(std::is_same_v<decltype(beluga::forward_like<const float&>(object)), const Object&>);
36  static_assert(std::is_same_v<decltype(beluga::forward_like<float&&>(object)), Object&>);
37  static_assert(std::is_same_v<decltype(beluga::forward_like<const float&&>(object)), const Object&&>);
38 }
39 
40 TEST(ForwardLike, ConstLvalue) {
41  const auto object = Object{};
42  static_assert(std::is_same_v<decltype(beluga::forward_like<float&>(object)), const Object&>);
43  static_assert(std::is_same_v<decltype(beluga::forward_like<const float&>(object)), const Object&>);
44  static_assert(std::is_same_v<decltype(beluga::forward_like<float&&>(object)), const Object&>);
45  static_assert(std::is_same_v<decltype(beluga::forward_like<const float&&>(object)), const Object&&>);
46 }
47 
48 TEST(ForwardLike, Value) {
49  const int value = 200;
50  ASSERT_EQ(beluga::forward_like<Object&>(50), 50);
51  ASSERT_EQ(beluga::forward_like<Object&>(value), 200);
52 }
53 
54 } // namespace
forward_like.hpp
beluga::TEST
TEST(Bresenham, MultiPassGuarantee)
Definition: test_bresenham.cpp:27


beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53