1 // $Id: AliHLTComponent.cxx 22571 2007-11-28 09:54:41Z richterm $
3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file dtOperators.cxx
20 @author Matthias Richter
22 @brief Test program for data type operators
26 #include "AliHLTDataTypes.h"
27 #include "AliHLTComponent.h"
31 typedef struct test_t {
32 AliHLTComponentDataType dt1;
33 AliHLTComponentDataType dt2;
34 int type; // 1 -> ==, 0 -> !=
38 int main(int /*argc*/, const char** /*argv*/)
40 AliHLTComponentDataType testdt1={
41 sizeof(AliHLTComponentDataType),
42 {'D','U','M','M','Y','D','A','T'},
45 AliHLTComponentDataType testdt2={
46 sizeof(AliHLTComponentDataType),
47 {'_','S','O','_','E','V','E','R'},
50 AliHLTComponentDataType testdt3={
51 sizeof(AliHLTComponentDataType),
52 {'D','U','M','M','Y','D','A','T'},
53 kAliHLTDataOriginAny};
55 AliHLTComponentDataType testdt4={
56 sizeof(AliHLTComponentDataType),
60 AliHLTComponentDataType testdt5={
61 sizeof(AliHLTComponentDataType),
62 {'D','D','L','_','R','A','W',' '},
66 {{kAliHLTDataTypeDDLRaw|"TRD "} , {testdt5 } , 1 , true },
67 {{kAliHLTDataTypeDDLRaw|"TRD "} , {testdt5 } , 0 , false},
69 {{kAliHLTDataTypeDDLRaw} , {testdt5 } , 1 , true },
70 {{kAliHLTDataTypeDDLRaw} , {testdt5 } , 0 , false},
72 // {{testdt1 } , {testdt1 } , 1 , true },
73 // {{testdt1 } , {testdt1 } , 0 , false},
75 {{testdt1 } , {testdt2 } , 1 , false},
76 {{testdt1 } , {testdt2 } , 0 , true },
78 {{testdt1 } , {testdt3 } , 1 , true },
79 {{testdt1 } , {testdt3 } , 0 , false},
81 {{testdt1 } , {testdt4 } , 1 , true },
82 {{testdt1 } , {testdt4 } , 0 , false},
84 {{testdt3 } , {testdt4 } , 1 , true },
85 {{testdt3 } , {testdt4 } , 0 , false},
87 {{testdt2 } , {testdt4 } , 1 , false},
88 {{testdt2 } , {testdt4 } , 0 , true },
90 {{testdt1 } , {kAliHLTAnyDataType } , 1 , true },
91 {{testdt1 } , {kAliHLTAnyDataType } , 0 , false},
94 {{kAliHLTAnyDataType } , {kAliHLTAnyDataType } , 1 , true },
95 {{kAliHLTAnyDataType } , {kAliHLTAnyDataType } , 0 , false},
97 {{kAliHLTVoidDataType} , {kAliHLTAnyDataType } , 1 , false},
98 {{kAliHLTVoidDataType} , {kAliHLTAnyDataType } , 0 , true },
100 {{kAliHLTVoidDataType} , {kAliHLTVoidDataType} , 1 , true },
101 {{kAliHLTVoidDataType} , {kAliHLTVoidDataType} , 0 , false},
103 {{kAliHLTVoidDataType} , {testdt5} , 1 , false },
104 {{kAliHLTVoidDataType} , {testdt5} , 0 , true},
106 {{kAliHLTVoidDataType|"TRD "} , {kAliHLTVoidDataType} , 1 , false },
107 {{kAliHLTVoidDataType|"TRD "} , {kAliHLTVoidDataType} , 0 , true },
109 {{kAliHLTVoidDataType|"TRD "} , {testdt5} , 1 , false },
110 {{kAliHLTVoidDataType|"TRD "} , {testdt5} , 0 , true },
114 cout << "checking data type operators" << endl;
115 for (unsigned int i=0; i<(sizeof(tests)/sizeof(test_t)); i++) {
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;
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 ";
126 cout << result << endl;
127 if (result^tests[i].result) return 1;