1 #ifndef __TEST_UTILS_H__ 2 #define __TEST_UTILS_H__ 8 #include <log4cplus/logger.h> 9 #include <log4cplus/loggingmacros.h> 18 #define KINETICA_STREAM_TO_STRING(...) ( static_cast<const std::ostringstream&> (std::ostringstream() << __VA_ARGS__).str() ) 23 #define KINETICA_STREAM_TO_CSTRING(...) ( KINETICA_STREAM_TO_STRING(__VA_ARGS__).c_str() ) 26 #define LOG_KINETICA_INFO(logger, logEvent) do { LOG4CPLUS_INFO(logger, logEvent); } while(0) 29 #define LOG_KINETICA_DEBUG(logger, logEvent) do { LOG4CPLUS_DEBUG(logger, logEvent); } while(0) 32 #define LOG_KINETICA_WARN(logger, logEvent) do { LOG4CPLUS_WARN(logger, logEvent); } while(0) 35 #define LOG_KINETICA_ERROR(logger, logEvent) do { LOG4CPLUS_ERROR(logger, logEvent); } while(0) 43 #define NORMALIZER 100 44 #define USE_NULL_VALUE(null_percentage) \ 45 ((std::rand() % NORMALIZER) < null_percentage) 47 #define PERFORM_ACTION( percentage ) \ 48 ((std::rand() % NORMALIZER) < percentage) 50 #define GENERATE_INT8() \ 51 ( (std::rand() % 256) - 128) 53 #define GENERATE_INT16() \ 54 ( (std::rand() % 65536) - 32768) 56 #define GENERATE_FLOAT() \ 57 ( ((float)std::rand()) / std::rand() * std::pow(-1, (std::rand() % 2)) ) 60 #define GENERATE_DOUBLE() \ 61 ( ((double)std::rand()) / std::rand() * std::pow(-1, (std::rand() % 2)) ) 63 #define GENERATE_TIMESTAMP() \ 64 ( std::rand() - std::rand() ) // Range is actually [-30610239758979, 29379542399999] 68 static const char alphanum[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
86 #define GENERATE_IPV4() \ 87 ( std::to_string(std::rand() % 256) + "." \ 88 + std::to_string(std::rand() % 256) + "." \ 89 + std::to_string(std::rand() % 256) + "." \ 90 + std::to_string(std::rand() % 256) ) 103 std::string
generate_datetime(
int chance_percentage_has_time,
int chance_percentage_has_ms );
116 std::string
generate_decimal(
int frac_only_percentage,
int has_frac_percentage,
int negative_percentage,
int positive_percentage );
129 const std::vector<gpudb::Type::Column>& columns);
138 #endif // __TEST_UTILS_H__ static const char alphanum[]
std::string generate_date()
static const int alphabet_size
std::string generate_datetime(int chance_percentage_has_time, int chance_percentage_has_ms)
std::string generate_time(int chance_percentage_has_ms)
void clear_table(const gpudb::GPUdb &db, const std::string table_name)
Clear a given table.
void create_table(const gpudb::GPUdb &db, const std::string table_name, const gpudb::Type &type)
Create a table given a DB hancle, table name, and a type.
std::string generate_random_string()
std::string generate_decimal(int frac_only_percentage, int has_frac_percentage, int negative_percentage, int positive_percentage)
std::string generate_charN(size_t N)