Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JRouter.cc File Reference

Example program to test JTOOLS::JRouter class. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "JTools/JRouter.hh"
#include "JLang/JObjectID.hh"
#include "JIO/JFileStreamIO.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JTOOLS::JRouter class.

Author
mdejong

Definition in file JRouter.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 21 of file JRouter.cc.

22{
23 using namespace std;
24 using namespace JPP;
25
26 int debug;
27
28 try {
29
30 JParser<> zap("Example program to test router.");
31
32 zap['d'] = make_field(debug) = 3;
33
34 zap(argc, argv);
35 }
36 catch(const exception &error) {
37 FATAL(error.what() << endl);
38 }
39
40 vector <int> buffer;
41 JRouter<int> router(-1);
42
43 {
44 buffer.clear();
45 router.clear();
46
47 for (int i = 1; i <= 1000000; i *= 10) {
48 buffer.push_back(i);
49 }
50
51 for (size_t i = 0; i != buffer.size(); ++i) {
52 router.put(buffer[i], i);
53 }
54
55 ASSERT(!router.in_range(0), "Test of router range.");
56 ASSERT(!router.has(2), "Test of router has.");
57
58 for (int i = 1; i <= 1000000; i *= 10) {
59 ASSERT(router.in_range(i), "Test of router range.");
60 ASSERT(router.has(i), "Test of router has.");
61 ASSERT(buffer[router.get(i)] == i, "Test of router lookup.");
62 }
63 }
64
65 {
66 buffer.clear();
67 router.clear();
68
69 for (int i = 1000000; i >= 1; i /= 10) {
70 buffer.push_back(i);
71 }
72
73 for (size_t i = 0; i != buffer.size(); ++i) {
74 router.put(buffer[i], i);
75 }
76
77 ASSERT(!router.in_range(0), "Test of router range.");
78 ASSERT(!router.has(2), "Test of router has.");
79
80 for (int i = 1000000; i >= 1; i /= 10) {
81 ASSERT(router.in_range(i), "Test of router range.");
82 ASSERT(router.has(i), "Test of router has.");
83 ASSERT(buffer[router.get(i)] == i, "Test of router.");
84 }
85 }
86
87 return 0;
88}
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
Direct addressing of elements with unique identifiers.
Definition JRouter.hh:27
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).