1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 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
|
// -*- c++ -*-
//------------------------------------------------------------------------------
// $Id: idset_test.cpp,v 1.2 2002/12/05 03:20:17 vlg Exp $
//------------------------------------------------------------------------------
//
// Name: idset_test.C
//
// Synopsis:
// % idset_test
//
// Description: test program for IdSet class functionality
//-----------------------------------------------------------------------
#include <iostream>
using namespace std;
#include "assa/Logger.h"
#include "assa/IdSet.h"
using namespace ASSA;
int main()
{
std::cout << "= Running id_set Test =\n";
int ret = 0;
int failed = 0;
cout << endl << "*** Test for id handling:" << endl;
IdSet ids;
if (ids.currid() == 0) {
cout << "Current = 0 ... ok" << endl;
}
else {
cout << "Current = " << ids.currid() << "... error" << endl;
failed++;
}
int i = ids.newid();
i = ids.newid();
if (i == 1) {
cout << "New = 1 ... ok" << endl;
}
else {
cout << "New = " << i << "... error" << endl;
failed++;
}
for (int j=i; j < 100; j++) {
i = ids.newid();
}
i = ids.currid();
if (i == 101) {
cout << "Current = 101 ... ok" << endl;
}
else {
cout << "Current = " << i << "... error" << endl;
failed++;
}
cout << endl << "*** Test recycling:" << endl;
ids.recycle(30);
ids.recycle(50);
ids.recycle(75);
i = ids.currid();
if (i == 30) {
cout << "Current = 30 ... ok" << endl;
}
else {
cout << "Current = " << i << "... error" << endl;
failed++;
}
i = ids.newid();
i = ids.newid();
if (i == 50) {
cout << "New = 50 ... ok" << endl;
}
else {
cout << "New = " << i << "... error" << endl;
failed++;
}
cout << endl;
if (failed) {
cout << failed << "tests failed\n";
}
else {
cout << "Test passed\n";
}
return ret;
}
|