]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/test/dtOperators.cxx
- AliHLTEsdManager: minor bufix -> correct error handling
[u/mrichter/AliRoot.git] / HLT / BASE / test / dtOperators.cxx
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
29 using namespace std;
30
31 typedef struct test_t {
32   AliHLTComponentDataType dt1;
33   AliHLTComponentDataType dt2;
34   int type; // 1 -> ==, 0 -> !=
35   bool result;
36 } test_t;
37
38 int main(int /*argc*/, const char** /*argv*/)
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[] = {
66     {{kAliHLTDataTypeDDLRaw|"TRD "} , {testdt5          }  , 1 , true },
67     {{kAliHLTDataTypeDDLRaw|"TRD "} , {testdt5          }  , 0 , false},
68
69     {{kAliHLTDataTypeDDLRaw} , {testdt5          }  , 1 , true },
70     {{kAliHLTDataTypeDDLRaw} , {testdt5          }  , 0 , false},
71
72 //     {{testdt1            } , {testdt1            }  , 1 , true },
73 //     {{testdt1            } , {testdt1            }  , 0 , false},
74
75     {{testdt1            } , {testdt2            }  , 1 , false},
76     {{testdt1            } , {testdt2            }  , 0 , true },
77
78     {{testdt1            } , {testdt3            }  , 1 , true },
79     {{testdt1            } , {testdt3            }  , 0 , false},
80
81     {{testdt1            } , {testdt4            }  , 1 , true },
82     {{testdt1            } , {testdt4            }  , 0 , false},
83
84     {{testdt3            } , {testdt4            }  , 1 , true },
85     {{testdt3            } , {testdt4            }  , 0 , false},
86
87     {{testdt2            } , {testdt4            }  , 1 , false},
88     {{testdt2            } , {testdt4            }  , 0 , true },
89
90     {{testdt1            } , {kAliHLTAnyDataType }  , 1 , true },
91     {{testdt1            } , {kAliHLTAnyDataType }  , 0 , false},
92
93     //
94     {{kAliHLTAnyDataType } , {kAliHLTAnyDataType }  , 1 , true },
95     {{kAliHLTAnyDataType } , {kAliHLTAnyDataType }  , 0 , false},
96
97     {{kAliHLTVoidDataType} , {kAliHLTAnyDataType }  , 1 , false},
98     {{kAliHLTVoidDataType} , {kAliHLTAnyDataType }  , 0 , true },
99
100     {{kAliHLTVoidDataType} , {kAliHLTVoidDataType}  , 1 , true },
101     {{kAliHLTVoidDataType} , {kAliHLTVoidDataType}  , 0 , false},
102
103     {{kAliHLTVoidDataType} , {testdt5}  , 1 , false },
104     {{kAliHLTVoidDataType} , {testdt5}  , 0 , true},
105
106     {{kAliHLTVoidDataType|"TRD "} , {kAliHLTVoidDataType}  , 1 , false },
107     {{kAliHLTVoidDataType|"TRD "} , {kAliHLTVoidDataType}  , 0 , true  },
108
109     {{kAliHLTVoidDataType|"TRD "} , {testdt5}  , 1 , false },
110     {{kAliHLTVoidDataType|"TRD "} , {testdt5}  , 0 , true },
111   };
112
113   int result=0;
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;
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 }