comma_list_tests.cpp

Go to the documentation of this file.
00001 
00011 #include <stdlib.h>
00012 
00013 #include <iostream>
00014 
00015 #include "comma_list.h"
00016 
00017 using namespace std;
00018 
00019 #define check(clist, val, result) \
00020     if (clist.match(val) != result) { \
00021         cerr << "\"" << #val << "\" matched with " #clist \
00022              << " did not return " #result << endl; \
00023         exit(EXIT_FAILURE); \
00024     }
00025 
00026 int main()
00027 {
00028     comma_list<int> c1;
00029 
00030     check(c1, 1, true);
00031 
00032     c1.set("2");
00033 
00034     check(c1, 2, true);
00035     check(c1, 3, false);
00036 
00037     c1.set("3");
00038 
00039     check(c1, 2, false);
00040     check(c1, 3, true);
00041 
00042     c1.set("2,3");
00043 
00044     check(c1, 2, true);
00045     check(c1, 3, true);
00046     check(c1, 4, false);
00047 
00048     c1.set("all");
00049 
00050     check(c1, 2, true);
00051     check(c1, 4, true);
00052     check(c1, 5, true);
00053 
00054     comma_list<int> c2;
00055 
00056     c2.set("6,all");
00057 
00058     check(c2, 4, true);
00059     check(c2, 0, true);
00060 
00061     c2.set("all,6");
00062 
00063     check(c2, 4, true);
00064     check(c2, 0, true);
00065 
00066     c2.set("10");
00067     check(c2, 10, true);
00068     check(c2, 11, false);
00069     return EXIT_SUCCESS;
00070 }

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1