38#include <gtest/gtest.h>
48TEST(AhUtilsTest, EvenOdd) {
62TEST(AhUtilsTest, NibbleConversion) {
63 for (
int i = 0; i < 16; ++i) {
80TEST(AhUtilsTest, PowerOf2) {
96#if SIZE_MAX > UINT32_MAX
99 constexpr size_t big = size_t(1) << 40;
109 constexpr size_t top = (std::numeric_limits<size_t>::max() >> 1) + 1;
114 std::overflow_error);
133TEST(AhUtilsTest, Interpolation) {
175 EXPECT_EQ(name,
"int");
180 EXPECT_TRUE(className.find(
"MyTestStruct") != std::string::npos);
185 std::string filename =
"test_exists_file.tmp";
186 std::ofstream outfile(filename);
191 std::remove(filename.c_str());
205 double inf = std::numeric_limits<double>::infinity();
206 double nan = std::numeric_limits<double>::quiet_NaN();
227 std::vector<int>::const_iterator
it;
228 std::vector<int>::const_iterator
end;
246 EXPECT_EQ(r1,
"vec <- c(1, 2, 3)");
252 EXPECT_EQ(r2,
"1 <- c(1, 2, 3)");
255int main(
int argc,
char **argv) {
256 ::testing::InitGoogleTest(&argc, argv);
257 return RUN_ALL_TESTS();
General utility functions and helpers.
#define CLASSNAME_TO_STRING(class_ptr)
Given a pointer, it returns the class name.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
double next_value(const double val)
Return the next representable floating-point value to val
size_t next_power_of_2(size_t x)
Return the smallest power of 2 that is not less than x.
void error_msg(const std::string &msg)
Display message and abort program execution.
bool is_power_of_2(size_t x)
Taken from http://stackoverflow.com/questions/3638431/determine-if-an-int-is-a-power-of-2-or-not-in-a...
const T * median(const T &a, const T &b, const T &c, const Compare &cmp=Compare())
Return a pointer to the median value among three elements.
constexpr bool are_near(const double v1, const double v2, const double e) noexcept
Return true if v1 is within absolute distance e of v2.
double extrapolate_right(const double x1, const double x2, const double y1, const double y2, const double x)
Basic linear extrapolation.
double interpolate(const double x1, const double x2, const double y1, const double y2, const double x)
Basic linear interpolation.
constexpr size_t l_index(const size_t i)
Map a binary heap index to the index of its left child.
constexpr size_t u_index(const size_t &i)
Map a binary heap index to the index of its parent.
double prev_value(const double val)
Return the next representable floating-point value of val towards the smallest positive normal number...
bool is_even(const long n)
Return true if n is even.
bool is_odd(const long n)
Return true if n is odd.
double pow2(const double x)
Return x^2.
char nibble_to_char(const int i)
Convert a 4-bit nibble stored in an int to its hex character.
bool exists_file(const std::string &name)
Return true if it exists a file of name
int char_to_nibble(const char c)
Convert a hex character in 0..9A..F to its 4-bit nibble value.
std::string Rvector(const std::string &name, const C &c)
Return a string with R specification of a vector with name and data stored in container c
bool is_normal_number(const double n)
Return true if a floating-point number is normal or zero.
std::string demangle(const char *name)
Given a linker symbol name generated by a c++ compiler, this functions decodes it into a user level n...
double extrapolate_left(const double x1, const double x2, const double y1, const double y2, const double x)
Basic linear extrapolation.
double pow3(const double x)
Return x^3.
std::vector< int >::const_iterator end
Iterator(const MockContainer &c)
std::vector< int >::const_iterator it
const int & get_curr() const
const int & get_last() const
MockContainer(std::initializer_list< int > l)
const int & get_first() const
Iterator get_it(int) const