00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "vfer_btree_delay.h"
00018 #include "vfer_tests.h"
00019
00020
00021
00022
00023 int main() {
00024 tree_t t;
00025 struct timeval tv;
00026 int r, j, min;
00027
00028 TEST_INIT("TEST_BTREE", "test_btree.c", stdout, stdout);
00029 srand(time(NULL));
00030
00031
00032 tv.tv_usec = 0;
00033 tv.tv_sec = 2;
00034 Tree_Init(&t, tv);
00035
00036
00037 tv.tv_sec = 1;
00038 Tree_Insert(&t, 5, tv);
00039 TEST_CHECK((Tree_Min(&t, tv) == 5), "Tree_Min[1] incorrect return value");
00040
00041
00042 tv.tv_sec = 4;
00043 Tree_Insert(&t, 6, tv);
00044 TEST_CHECK((Tree_Min(&t, tv) == 6), "Tree_Min[2] incorrect return value");
00045
00046
00047 tv.tv_sec = 6;
00048 Tree_Insert(&t, 7, tv);
00049 TEST_CHECK((Tree_Min(&t, tv) == 6), "Tree_Min[3] incorrect return value");
00050
00051
00052 tv.tv_sec = 9;
00053 TEST_CHECK((Tree_Min(&t, tv) == 7), "Tree_Min[4] incorrect return value");
00054
00055
00056
00057 tv.tv_sec = 256;
00058 Tree_Set_Window(&t, tv);
00059 min = 128;
00060 for (j = 0; j < 256; j++) {
00061 tv.tv_sec = j;
00062 r = rand() % 128;
00063 if (r < min) min = r;
00064 Tree_Insert(&t, r, tv);
00065 TEST_CHECK((Tree_Min(&t, tv) == min), "Tree_Min[loop] incorrect return value");
00066 }
00067
00068
00069
00070
00071 for (j = 0; j < 256; j++) {
00072 tv.tv_sec = 256+j;
00073 Tree_Insert(&t, j, tv);
00074 }
00075 for (j = 0; j < 256; j++) {
00076 tv.tv_sec = 512+j;
00077 TEST_CHECK((Tree_Min(&t, tv) == j), "Tree_Min[loop2] incorrect return value");
00078 }
00079
00080 TEST_SUMMARY();
00081 return 0;
00082 }