]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/test/dtOperators.cxx
adding a component for statistics and monitoring of the DAQ readout list
[u/mrichter/AliRoot.git] / HLT / BASE / test / dtOperators.cxx
CommitLineData
853121af 1// $Id: AliHLTComponent.cxx 22571 2007-11-28 09:54:41Z richterm $
2
3/**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
6 * *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18
19/** @file dtOperators.cxx
20 @author Matthias Richter
21 @date
22 @brief Test program for data type operators
23 */
24
25#include <iostream>
26#include "AliHLTDataTypes.h"
27#include "AliHLTComponent.h"
28
29using namespace std;
30
31typedef struct test_t {
32 AliHLTComponentDataType dt1;
33 AliHLTComponentDataType dt2;
34 int type; // 1 -> ==, 0 -> !=
35 bool result;
36} test_t;
37
3dd8541e 38int main(int /*argc*/, const char** /*argv*/)
853121af 39{
40 AliHLTComponentDataType testdt1={
41 sizeof(AliHLTComponentDataType),
42 {'D','U','M','M','Y','D','A','T'},
43 {'T','E','S','T'}};
44
45 AliHLTComponentDataType testdt2={
46 sizeof(AliHLTComponentDataType),
47 {'_','S','O','_','E','V','E','R'},
48 {'W','H','A','T'}};
49
50 AliHLTComponentDataType testdt3={
51 sizeof(AliHLTComponentDataType),
52 {'D','U','M','M','Y','D','A','T'},
53 kAliHLTDataOriginAny};
54
55 AliHLTComponentDataType testdt4={
56 sizeof(AliHLTComponentDataType),
57 kAliHLTAnyDataTypeID,
58 {'T','E','S','T'}};
59
60 AliHLTComponentDataType testdt5={
61 sizeof(AliHLTComponentDataType),
62 {'D','D','L','_','R','A','W',' '},
63 {'T','R','D',' '}};
64
65 test_t tests[] = {
0dc0a0f2 66 {kAliHLTDataTypeDDLRaw|"TRD " , testdt5 , 1 , true },
67 {kAliHLTDataTypeDDLRaw|"TRD " , testdt5 , 0 , false},
853121af 68
0dc0a0f2 69 {kAliHLTDataTypeDDLRaw , testdt5 , 1 , true },
70 {kAliHLTDataTypeDDLRaw , testdt5 , 0 , false},
853121af 71
0dc0a0f2 72// {testdt1 , testdt1 , 1 , true },
73// {testdt1 , testdt1 , 0 , false},
853121af 74
0dc0a0f2 75 {testdt1 , testdt2 , 1 , false},
76 {testdt1 , testdt2 , 0 , true },
853121af 77
0dc0a0f2 78 {testdt1 , testdt3 , 1 , true },
79 {testdt1 , testdt3 , 0 , false},
853121af 80
0dc0a0f2 81 {testdt1 , testdt4 , 1 , true },
82 {testdt1 , testdt4 , 0 , false},
853121af 83
0dc0a0f2 84 {testdt3 , testdt4 , 1 , true },
85 {testdt3 , testdt4 , 0 , false},
853121af 86
0dc0a0f2 87 {testdt2 , testdt4 , 1 , false},
88 {testdt2 , testdt4 , 0 , true },
853121af 89
0dc0a0f2 90 {testdt1 , kAliHLTAnyDataType , 1 , true },
91 {testdt1 , kAliHLTAnyDataType , 0 , false},
853121af 92
93 //
0dc0a0f2 94 {kAliHLTAnyDataType , kAliHLTAnyDataType , 1 , true },
95 {kAliHLTAnyDataType , kAliHLTAnyDataType , 0 , false},
853121af 96
0dc0a0f2 97 {kAliHLTVoidDataType , kAliHLTAnyDataType , 1 , false},
98 {kAliHLTVoidDataType , kAliHLTAnyDataType , 0 , true },
853121af 99
0dc0a0f2 100 {kAliHLTVoidDataType , kAliHLTVoidDataType , 1 , true },
101 {kAliHLTVoidDataType , kAliHLTVoidDataType , 0 , false},
853121af 102
0dc0a0f2 103 {kAliHLTVoidDataType , testdt5 , 1 , false },
104 {kAliHLTVoidDataType , testdt5 , 0 , true},
853121af 105
0dc0a0f2 106 {kAliHLTVoidDataType|"TRD " , kAliHLTVoidDataType , 1 , false },
107 {kAliHLTVoidDataType|"TRD " , kAliHLTVoidDataType , 0 , true },
853121af 108
0dc0a0f2 109 {kAliHLTVoidDataType|"TRD " , testdt5 , 1 , false },
110 {kAliHLTVoidDataType|"TRD " , testdt5 , 0 , true },
853121af 111 };
112
113 int result=0;
114 cout << "checking data type operators" << endl;
3dd8541e 115 for (unsigned int i=0; i<(sizeof(tests)/sizeof(test_t)); i++) {
853121af 116 //if (!tests[i].type) continue;
117 const char* op=(tests[i].type)?" == ":" != ";
118 cout << "checking: " << AliHLTComponent::DataType2Text(tests[i].dt1).c_str() << op << AliHLTComponent::DataType2Text(tests[i].dt2).c_str() << " -> ";
119 if (tests[i].type) result=tests[i].dt1==tests[i].dt2;
120 else result=tests[i].dt1!=tests[i].dt2;
121 if (result) {
122 if (tests[i].type) result=tests[i].dt2==tests[i].dt1;
123 else result=tests[i].dt2!=tests[i].dt1;
124 if (!result) cout << " interchanged sequence ";
125 }
126 cout << result << endl;
127 if (result^tests[i].result) return 1;
128 }
129
130 return 0;
131}