IODA Bundle
TestBitfields.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2012 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 /// \file UnitTest.h
12 ///
13 /// @author Piotr Kuchta, ECMWF, Feb 2009
14 
15 #include "eckit/log/Log.h"
16 #include "odc/core/MetaData.h"
17 #include "odc/Select.h"
18 
19 #include "TestCase.h"
20 
21 using namespace std;
22 using namespace eckit;
23 using namespace odc;
24 
25 /// UnitTest problem fixed with p4 change 23687
26 ///
27 static void test()
28 {
29  string statusFields =
30 "status.active@body,status.passive@body,status.rejected@body,status.blacklisted@body,status.monthly@body,status.constant@body,status.experimental@body,status.whitelist@body";
31 
32  statusFields = "status.*@body";
33  const string SELECT = std::string("select status@body, ") + statusFields + " from \"2000010106.odb\";";
34 
35  Log::info() << "Executing '" << SELECT << "'" << std::endl;
36 
37  odc::Select oda(SELECT);
38  long int i=0;
39 
40  odc::Select::iterator it = oda.begin();
41 
42  ASSERT(it->columns().size() == 9);
43 
44  for ( ; it != oda.end() && i < 5000; ++it, ++i)
45  {
46  unsigned int sum =
47  int ((*it)[1])
48  | int ((*it)[2]) << 1
49  | int ((*it)[3]) << 2
50  | int ((*it)[4]) << 3
51  | int ((*it)[5]) << 4
52  | int ((*it)[6]) << 5
53  | int ((*it)[7]) << 6
54  | int ((*it)[8]) << 7;
55 // Log::info() << i << ": " << (*it)[0] << " " << sum << std::endl;
56  ASSERT((*it)[0] == sum);
57  }
58 }
59 
60 
61 
62 static void setUp(){}
63 static void tearDown(){}
64 
65 SIMPLE_TEST(Bitfields)
void oda
static void tearDown()
static void test()
static void setUp()
#define SIMPLE_TEST(name)
Definition: TestCase.h:66
const core::MetaData & columns() const
Definition: IteratorProxy.h:94
Definition: ColumnInfo.h:23
Definition: encode.cc:30