OmniSciDB  343343d194
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TestHelpers Namespace Reference

Classes

struct  GeoTargetComparator
 
struct  ValuesGenerator
 

Functions

template<class T >
void compare_array (const TargetValue &r, const std::vector< T > &arr, const double tol=-1.)
 
template<>
void compare_array (const TargetValue &r, const std::vector< std::string > &arr, const double tol)
 
template<class T >
void compare_array (const std::vector< T > &a, const std::vector< T > &b, const double tol=-1.)
 
template<class T >
g (const TargetValue &r)
 
template<class T >
void compare_geo_target (const TargetValue &r, const T &geo_truth_target, const double tol=-1.)
 
template<class T >
v (const TargetValue &r)
 
template<typename T >
std::string convert (const T &t)
 
template<std::size_t N>
std::string convert (const char(&t)[N])
 
template<>
std::string convert (const std::string &t)
 
LeafHostInfo to_leaf_host_info (std::string &server_info, NodeRole role)
 
std::vector< LeafHostInfoto_leaf_host_info (std::vector< std::string > &server_infos, NodeRole role)
 
void init_logger_stderr_only (int argc, char const *const *argv)
 

Function Documentation

template<class T >
void TestHelpers::compare_array ( const TargetValue r,
const std::vector< T > &  arr,
const double  tol = -1. 
)

Definition at line 33 of file TestHelpers.h.

References CHECK, and tol().

Referenced by TestHelpers::GeoTargetComparator::compare(), and TEST().

35  {
36  auto array_tv = boost::get<ArrayTargetValue>(&r);
37  CHECK(array_tv);
38  if (!array_tv->is_initialized()) {
39  ASSERT_EQ(size_t(0), arr.size());
40  return;
41  }
42  const auto& scalar_tv_vector = array_tv->get();
43  ASSERT_EQ(scalar_tv_vector.size(), arr.size());
44  size_t ctr = 0;
45  for (const ScalarTargetValue scalar_tv : scalar_tv_vector) {
46  auto p = boost::get<T>(&scalar_tv);
47  if (tol < 0.) {
48  ASSERT_EQ(*p, arr[ctr++]);
49  } else {
50  ASSERT_NEAR(*p, arr[ctr++], tol);
51  }
52  }
53 }
#define CHECK(condition)
Definition: Logger.h:187
DEVICE ALWAYS_INLINE double tol(int32_t ic)
boost::variant< int64_t, double, float, NullableString > ScalarTargetValue
Definition: TargetValue.h:156

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<>
void TestHelpers::compare_array ( const TargetValue r,
const std::vector< std::string > &  arr,
const double  tol 
)

Definition at line 56 of file TestHelpers.h.

References CHECK.

58  {
59  auto array_tv = boost::get<ArrayTargetValue>(&r);
60  CHECK(array_tv);
61  if (!array_tv->is_initialized()) {
62  ASSERT_EQ(size_t(0), arr.size());
63  return;
64  }
65  const auto& scalar_tv_vector = array_tv->get();
66  ASSERT_EQ(scalar_tv_vector.size(), arr.size());
67  size_t ctr = 0;
68  for (const ScalarTargetValue scalar_tv : scalar_tv_vector) {
69  auto ns = boost::get<NullableString>(&scalar_tv);
70  CHECK(ns);
71  auto str = boost::get<std::string>(ns);
72  CHECK(str);
73  ASSERT_TRUE(*str == arr[ctr++]);
74  }
75 }
#define CHECK(condition)
Definition: Logger.h:187
boost::variant< int64_t, double, float, NullableString > ScalarTargetValue
Definition: TargetValue.h:156
template<class T >
void TestHelpers::compare_array ( const std::vector< T > &  a,
const std::vector< T > &  b,
const double  tol = -1. 
)

Definition at line 78 of file TestHelpers.h.

References CHECK_EQ, and tol().

80  {
81  CHECK_EQ(a.size(), b.size());
82  for (size_t i = 0; i < a.size(); i++) {
83  if (tol < 0.) {
84  ASSERT_EQ(a[i], b[i]);
85  } else {
86  ASSERT_NEAR(a[i], b[i], tol);
87  }
88  }
89 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
DEVICE ALWAYS_INLINE double tol(int32_t ic)

+ Here is the call graph for this function:

template<class T >
void TestHelpers::compare_geo_target ( const TargetValue r,
const T &  geo_truth_target,
const double  tol = -1. 
)

Definition at line 127 of file TestHelpers.h.

References TestHelpers::GeoTargetComparator::compare(), and tol().

Referenced by TEST().

129  {
130  const auto geo_value = g<T>(r);
131  GeoTargetComparator::compare(geo_value, geo_truth_target, tol);
132 }
DEVICE ALWAYS_INLINE double tol(int32_t ic)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
std::string TestHelpers::convert ( const T &  t)
inline

Definition at line 144 of file TestHelpers.h.

References to_string().

Referenced by TestHelpers::ValuesGenerator::operator()().

144  {
145  return std::to_string(t);
146 }
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<std::size_t N>
std::string TestHelpers::convert ( const char(&)  t[N])
inline

Definition at line 149 of file TestHelpers.h.

149  {
150  return std::string(t);
151 }
template<>
std::string TestHelpers::convert ( const std::string &  t)
inline

Definition at line 154 of file TestHelpers.h.

154  {
155  return t;
156 }
template<class T >
T TestHelpers::g ( const TargetValue r)

Definition at line 118 of file TestHelpers.h.

References CHECK.

Referenced by Grantee::checkCycles(), anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::fill_storage_buffer_baseline_sort_fp(), anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::fill_storage_buffer_baseline_sort_int(), Parser::QuerySpec::QuerySpec(), and Analyzer::Query::set_group_by().

118  {
119  auto geo_r = boost::get<GeoTargetValue>(&r);
120  CHECK(geo_r);
121  auto p = boost::get<T>(geo_r);
122  CHECK(p);
123  return *p;
124 }
#define CHECK(condition)
Definition: Logger.h:187

+ Here is the caller graph for this function:

void TestHelpers::init_logger_stderr_only ( int  argc,
char const *const *  argv 
)

Definition at line 194 of file TestHelpers.h.

References logger::init(), logger::LogOptions::max_files_, and logger::LogOptions::parse_command_line().

Referenced by main().

194  {
195  logger::LogOptions log_options(argv[0]);
196  log_options.max_files_ = 0; // stderr only by default
197  log_options.parse_command_line(argc, argv);
198  logger::init(log_options);
199 }
void init(LogOptions const &log_opts)
Definition: Logger.cpp:260

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LeafHostInfo TestHelpers::to_leaf_host_info ( std::string &  server_info,
NodeRole  role 
)

Definition at line 171 of file TestHelpers.h.

Referenced by to_leaf_host_info().

171  {
172  size_t pos = server_info.find(':');
173  if (pos == std::string::npos) {
174  throw std::runtime_error("Invalid host:port -> " + server_info);
175  }
176 
177  auto host = server_info.substr(0, pos);
178  auto port = server_info.substr(pos + 1);
179 
180  return LeafHostInfo(host, std::stoi(port), role);
181 }

+ Here is the caller graph for this function:

std::vector<LeafHostInfo> TestHelpers::to_leaf_host_info ( std::vector< std::string > &  server_infos,
NodeRole  role 
)

Definition at line 183 of file TestHelpers.h.

References to_leaf_host_info().

184  {
185  std::vector<LeafHostInfo> host_infos;
186 
187  for (auto& server_info : server_infos) {
188  host_infos.push_back(to_leaf_host_info(server_info, role));
189  }
190 
191  return host_infos;
192 }
LeafHostInfo to_leaf_host_info(std::string &server_info, NodeRole role)
Definition: TestHelpers.h:171

+ Here is the call graph for this function:

template<class T >
T TestHelpers::v ( const TargetValue r)

Definition at line 135 of file TestHelpers.h.

References CHECK.

135  {
136  auto scalar_r = boost::get<ScalarTargetValue>(&r);
137  CHECK(scalar_r);
138  auto p = boost::get<T>(scalar_r);
139  CHECK(p);
140  return *p;
141 }
#define CHECK(condition)
Definition: Logger.h:187