OmniSciDB  c07336695a
ExperimentalTest.cpp File Reference
#include "../Shared/ConstExprLib.h"
#include "../Shared/ExperimentalTypeUtilities.h"
#include "TestHelpers.h"
#include <gtest/gtest.h>
#include <exception>
+ Include dependency graph for ExperimentalTest.cpp:

Go to the source code of this file.

Functions

constexpr ConstExprPair< int, int > yield_test_constexpr_pair ()
 
 TEST (ExperimentalTest, ConstExprLib_Pair)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 57 of file ExperimentalTest.cpp.

References logger::ERROR, TestHelpers::init_logger_stderr_only(), and LOG.

57  {
59  ::testing::InitGoogleTest(&argc, argv);
60 
61  int err{0};
62  try {
63  err = RUN_ALL_TESTS();
64  } catch (const std::exception& e) {
65  LOG(ERROR) << e.what();
66  }
67  return err;
68 }
#define LOG(tag)
Definition: Logger.h:182
void init_logger_stderr_only(int argc, char const *const *argv)
Definition: TestHelpers.h:194
+ Here is the call graph for this function:

◆ TEST()

TEST ( ExperimentalTest  ,
ConstExprLib_Pair   
)

Definition at line 32 of file ExperimentalTest.cpp.

References Experimental::ConstExprPair< T1, T2 >::first, Experimental::ConstExprPair< T1, T2 >::second, Experimental::ConstExprPair< T1, T2 >::swap(), and yield_test_constexpr_pair().

32  {
33  // Verify run-time use
34  ConstExprPair<int, int> default_construct1, default_construct2(1, 2);
35  ASSERT_EQ(default_construct1.first, 0);
36  ASSERT_EQ(default_construct1.second, 0);
37 
38  default_construct1.swap(default_construct2);
39  ASSERT_EQ(default_construct1.first, 1);
40  ASSERT_EQ(default_construct1.second, 2);
41 
42  ConstExprPair<int, int> component_construct1(1, 1), component_construct2(2, 2);
43  component_construct1 = component_construct2;
44  ASSERT_EQ(component_construct1.first, 2);
45  ASSERT_EQ(component_construct1.second, 2);
46 
47  ConstExprPair<int, int> component_construct3(component_construct2);
48  ASSERT_EQ(component_construct3.first, 2);
49  ASSERT_EQ(component_construct3.second, 2);
50 
51  // Verify compile time use
52  constexpr auto compile_time_verify = yield_test_constexpr_pair();
53  ASSERT_EQ(compile_time_verify.first, 2);
54  ASSERT_EQ(compile_time_verify.second, 2);
55 }
constexpr ConstExprPair< int, int > yield_test_constexpr_pair()
constexpr void swap(ConstExprPair &other) noexcept
Definition: ConstExprLib.h:25
+ Here is the call graph for this function:

◆ yield_test_constexpr_pair()

constexpr ConstExprPair<int, int> yield_test_constexpr_pair ( )

Definition at line 10 of file ExperimentalTest.cpp.

References Experimental::ConstExprPair< T1, T2 >::first, Experimental::ConstExprPair< T1, T2 >::second, and Experimental::ConstExprPair< T1, T2 >::swap().

Referenced by TEST().

10  {
11  ConstExprPair<int, int> default_construct1, default_construct2(1, 2);
12  if (!(default_construct1.first == 0 && default_construct1.second == 0)) {
13  throw std::runtime_error("Faulty construction");
14  }
15  default_construct1.swap(default_construct2);
16  if (!(default_construct1.first == 1 && default_construct1.second == 2)) {
17  throw std::runtime_error("Faulty swap");
18  }
19  ConstExprPair<int, int> component_construct1(1, 1), component_construct2(2, 2);
20  component_construct1 = component_construct2;
21  if (!(component_construct1.first == 2 && component_construct1.second == 2)) {
22  throw std::runtime_error("Faulty construction");
23  }
24  ConstExprPair<int, int> component_construct3(component_construct2);
25  if (!(component_construct3.first == 2 && component_construct3.second == 2)) {
26  throw std::runtime_error("Faulty component construction");
27  }
28 
29  return component_construct3;
30 }
constexpr void swap(ConstExprPair &other) noexcept
Definition: ConstExprLib.h:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function: