source: trunk/symtab/test/pool_test.cpp @ 1972

Last change on this file since 1972 was 1972, checked in by ksherdy, 7 years ago

Add test resources.

File size: 1.1 KB
Line 
1/*
2 * Created on: 18-December-2011
3 * Author: Ken Herdy
4 *
5 * Quick and dirty driver.
6 * Adds randomly lengthed string of bytes to the byte pool.
7 * Destroys object.
8 *
9 */
10
11#include "../lib/byte_pool.hpp"
12#include "../lib/allocator.hpp"
13
14#include <stdlib.h>
15#include <time.h>
16
17
18#include <iostream>
19using namespace std;
20
21int main() {
22
23    /* initialize random seed: */
24    int srand ( time(NULL) );
25    int random_value;
26
27    byte_pool<fast_pool_allocator<1024> > pool(1024);
28
29    uint8_t data [] = {65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116};
30
31    for(int i=0;i<65536;i++) {
32
33        random_value = rand() % 52 + 1;
34
35        cout << random_value << endl;
36        uint8_t * data_ptr = (uint8_t *) pool.insert(data,random_value);
37        cout << random_value << endl;
38        cout << random_value << ":" << hex << (uint64_t)data_ptr << " -> ";
39            for(int j=0;j<random_value;j++) {
40                cout << (char) data_ptr[j];
41        }
42        cout << endl;
43
44    }
45
46    cout << "Done." << endl;
47
48    return 0;
49}
Note: See TracBrowser for help on using the repository browser.