static gboolean test_file (const char *path) { FILE *file; GMimeStream *stream; gboolean rv; stream = NULL; file = NULL; file = fopen (path, "r"); if (!file) { g_warning ("cannot open file '%s': %s", path, strerror(errno)); rv = FALSE; goto leave; } stream = g_mime_stream_file_new (file); if (!stream) { g_warning ("cannot open stream for '%s'", path); rv = FALSE; goto leave; } rv = test_stream (stream); /* test-stream will unref it */ leave: if (file) fclose (file); return rv; }
int main() { std::vector<std::tuple<long,float,float>> rdata; //populates rdata for ( int i= 0 ; i< 1600;i++) { std::tuple<long,float,float> t = std::make_tuple(i, i/1.0 ,0); rdata.emplace_back(t); } quotek::data::records r1(rdata); test_construct(r1); test_down_sample(r1); test_stream(r1); exit(0); }
// Test basic interface int test(int argc, const char *argv[]) { // Bad data to compress! char *data = (char *)malloc(DATA_SIZE); for(int l = 0; l < DATA_SIZE; ++l) { data[l] = l*23; } // parameters about compression int maxOutput = Compress_MaxSizeForCompressedData(DATA_SIZE); TEST_THAT(maxOutput >= DATA_SIZE); char *compressed = (char *)malloc(maxOutput); int compressedSize = 0; // Do compression, in small chunks { Compress<true> compress; int in_loc = 0; while(!compress.OutputHasFinished()) { int ins = DATA_SIZE - in_loc; if(ins > CHUNK_SIZE) ins = CHUNK_SIZE; if(ins == 0) { compress.FinishInput(); } else { compress.Input(data + in_loc, ins); } in_loc += ins; // Get output data int s = 0; do { TEST_THAT(compressedSize < maxOutput); s = compress.Output(compressed + compressedSize, maxOutput - compressedSize); compressedSize += s; } while(s > 0); } } // a reasonable test, especially given the compressability of the input data. TEST_THAT(compressedSize < DATA_SIZE); // decompression char *decompressed = (char*)malloc(DATA_SIZE * 2); int decomp_size = 0; { Compress<false> decompress; int in_loc = 0; while(!decompress.OutputHasFinished()) { int ins = compressedSize - in_loc; if(ins > DECOMP_CHUNK_SIZE) ins = DECOMP_CHUNK_SIZE; if(ins == 0) { decompress.FinishInput(); } else { decompress.Input(compressed + in_loc, ins); } in_loc += ins; // Get output data int s = 0; do { TEST_THAT(decomp_size <= DATA_SIZE); s = decompress.Output(decompressed + decomp_size, (DATA_SIZE*2) - decomp_size); decomp_size += s; } while(s > 0); } } TEST_THAT(decomp_size == DATA_SIZE); TEST_THAT(::memcmp(data, decompressed, DATA_SIZE) == 0); ::free(data); ::free(compressed); ::free(decompressed); return test_stream(); }
int main(int argc, char* argv[]) { if (argc > 1 && argv[1] == std::string("test")) { return main_test(argc, argv); } loguru::init(argc, argv); // auto verbose_type_name = loguru::demangle(typeid(std::ofstream).name()); // loguru::add_stack_cleanup(verbose_type_name.c_str(), "std::ofstream"); // std::ofstream os; // die(os); if (argc == 1) { loguru::add_file("latest_readable.log", loguru::Truncate, loguru::Verbosity_INFO); loguru::add_file("everything.log", loguru::Append, loguru::Verbosity_MAX); LOG_F(INFO, "Loguru test"); test_thread_names(); test_scopes(); test_levels(); test_stream(); } else { std::string test = argv[1]; if (test == "ABORT_F") { ABORT_F("ABORT_F format message"); } else if (test == "ABORT_S") { ABORT_S() << "ABORT_S stream message"; } else if (test == "assert") { const char* ptr = 0; assert(ptr && "Error that was unexpected"); } else if (test == "LOG_F(FATAL)") { LOG_F(FATAL, "Fatal format message"); } else if (test == "LOG_S(FATAL)") { LOG_S(FATAL) << "Fatal stream message"; } else if (test == "CHECK_NOTNULL_F") { const char* ptr = 0; CHECK_NOTNULL_F(ptr); } else if (test == "CHECK_F") { CHECK_F(1 > 2); } else if (test == "CHECK_EQ_F") { CHECK_EQ_F(always_increasing(), 0); CHECK_EQ_F(always_increasing(), 1); CHECK_EQ_F(always_increasing(), 42); } else if (test == "CHECK_EQ_F_int") { int x = 42; CHECK_EQ_F(x, x + 1); } else if (test == "CHECK_EQ_F_unsigned") { unsigned x = 42; CHECK_EQ_F(x, x + 1); } else if (test == "CHECK_EQ_F_size_t") { size_t x = 42; CHECK_EQ_F(x, x + 1); } else if (test == "CHECK_EQ_F_message") { CHECK_EQ_F(always_increasing(), 0, "Should pass"); CHECK_EQ_F(always_increasing(), 1, "Should pass"); CHECK_EQ_F(always_increasing(), 42, "Should fail"); } else if (test == "CHECK_EQ_S") { std::string str = "right"; CHECK_EQ_S(str, "wrong") << "Expected to fail, since `str` isn't \"wrong\" but \"" << str << "\""; } else if (test == "CHECK_LT_S") { CHECK_EQ_S(always_increasing(), 0); CHECK_EQ_S(always_increasing(), 1); CHECK_EQ_S(always_increasing(), 42); } else if (test == "CHECK_LT_S_message") { CHECK_EQ_S(always_increasing(), 0) << "Should pass"; CHECK_EQ_S(always_increasing(), 1) << "Should pass"; CHECK_EQ_S(always_increasing(), 42) << "Should fail!"; } else if (test == "deep_abort") { deep_abort_10({"deep_abort"}); } else if (test == "SIGSEGV") { test_SIGSEGV_2(); } else if (test == "hang") { test_hang_2(); } else { LOG_F(ERROR, "Unknown test: '%s'", test.c_str()); } } }