38#include <gtest/gtest.h>
39#include "../ahUtils.H"
45TEST(AhUtilsTest, EvenOdd) {
59TEST(AhUtilsTest, NibbleConversion) {
60 for (
int i = 0; i < 16; ++i) {
77TEST(AhUtilsTest, PowerOf2) {
110TEST(AhUtilsTest, Interpolation) {
139 EXPECT_EQ(name,
"int");
144 EXPECT_TRUE(className.find(
"MyTestStruct") != std::string::npos);
149 std::string filename =
"test_exists_file.tmp";
150 std::ofstream outfile(filename);
155 std::remove(filename.c_str());
169 double inf = std::numeric_limits<double>::infinity();
170 double nan = std::numeric_limits<double>::quiet_NaN();
191 std::vector<int>::const_iterator
it;
192 std::vector<int>::const_iterator
end;
210 EXPECT_EQ(r1,
"vec <- c(1, 2, 3)");
216 EXPECT_EQ(r2,
"1 <- c(1, 2, 3)");
219int main(
int argc,
char **argv) {
220 ::testing::InitGoogleTest(&argc, argv);
221 return RUN_ALL_TESTS();
#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)
size_t l_index(const size_t i)
Map a binary heap index to the index of its left child.
double next_value(const double val)
Return the next representable floating-point value to val
unsigned long next_power_of_2(unsigned long x)
In x is not exact power of 2, it returns the next power of 2.
void error_msg(const std::string &msg)
Display message and abort program execution.
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.
size_t u_index(const size_t &i)
Map a binary heap index to the index of its parent.
double interpolate(const double x1, const double x2, const double y1, const double y2, const double x)
Basic linear interpolation.
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.
bool is_power_of_2(unsigned long x)
Taken from http://stackoverflow.com/questions/3638431/determine-if-an-int-is-a-power-of-2-or-not-in-a...
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