IODA Bundle
TestSelectTwoFiles.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 "odc/Select.h"
16 
17 #include "odc/utility/Tracer.h"
18 #include "odc/Writer.h"
19 #include "TestCase.h"
20 
21 using namespace std;
22 using namespace eckit;
23 using namespace odc;
24 using namespace odc::utility;
25 
26 static void setUp()
27 {
28  Tracer t(Log::debug(), "setUp");
29  {
30  odc::Writer<> f("TestSelectTwoFiles1.odb");
31  odc::Writer<>::iterator it = f.begin();
32  it->setNumberOfColumns(1);
33  it->setColumn(0, "a", odc::api::REAL);
34  it->writeHeader();
35  (*it)[0] = 1;
36  ++it;
37  }
38  {
39  odc::Writer<> f("TestSelectTwoFiles2.odb");
40  odc::Writer<>::iterator it = f.begin();
41  it->setNumberOfColumns(1);
42  it->setColumn(0, "b", odc::api::REAL);
43  it->writeHeader();
44  (*it)[0] = 2;
45  ++it;
46  }
47 }
48 
49 static void test()
50 {
51  Tracer t(Log::debug(), "test");
52 
53  odc::Select s("select * from \"TestSelectTwoFiles1.odb\", \"TestSelectTwoFiles2.odb\";");
55  odc::Select::iterator end = s.end();
56 
57  ASSERT(it->columns().size() == 2);
58 
59  unsigned long i = 0;
60  for (; it != end; ++it)
61  {
62  Log::debug() << "test: " << (*it)[0] << " " << (*it)[0] << std::endl;
63 
64  ASSERT( ((*it)[0] == 1) && ((*it)[1] == 2) );
65  ++i;
66  }
67 
68  ASSERT(i == 1);
69 }
70 
71 static void tearDown() { }
72 
73 SIMPLE_TEST(SelectTwoFiles)
#define SIMPLE_TEST(name)
Definition: TestCase.h:66
static void tearDown()
static void test()
static void setUp()
void writeHeader()
void setNumberOfColumns(size_t n)
Definition: IteratorProxy.h:95
const core::MetaData & columns() const
Definition: IteratorProxy.h:94
int setColumn(size_t index, const std::string &name, api::ColumnType type)
const iterator end()
Definition: Select.cc:77
iterator begin()
Definition: Select.cc:81
Definition: ColumnInfo.h:23
Definition: encode.cc:30