blob: 49dac5d8affb433698ab9cd453a01888c407e65f [file] [log] [blame]
#include <stdlib.h> // size_t
#include <assert.h> // assert
#include "median.h"
#include "hex.h"
#define TEST_SIZE 1024*1024*128 // 128M
// A sinple main routine meant as an example,
// and also to unit test most of the intersting
// functions of the median module.
int main(int argc, char * argv[]) {
// Call suggest buffer size to determine the size of the buffer
// we need to build the data structure.
size_t n = 0;
assert(median_suggest_buffer_size(.001, TEST_SIZE , &n) == MEDIAN_OK);
// Allocate the buffer of the required size. And then
// initialize it (median_init_buffer).
void * b = malloc(n);
median_buffer_t buf;
assert(median_init_buffer(b, n, .001, TEST_SIZE, &buf) == MEDIAN_OK);
// Insert some data.
for(median_data_t i = 1; i < TEST_SIZE; i++) { // 1G
assert(median_insert_data(buf,i) == MEDIAN_OK);
}
// Dump it.
assert(median_dump_stderr(buf) == MEDIAN_OK);
// All done, return 0
return 0;
}