IODA Bundle
TestAggregateFunctions3.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 TestAggregateFunctions3.h
12 ///
13 /// @author Piotr Kuchta, ECMWF, September 2010
14 
15 #include "eckit/io/FileHandle.h"
16 
17 #include "odc/Select.h"
18 
19 #include "odc/api/Odb.h"
20 #include "TestCase.h"
21 
22 using namespace std;
23 using namespace eckit;
24 using namespace odc;
25 
26 static void test()
27 {
28  string sql = "select sum(a) from \"TestAggregateFunctions3.odb\";";
29 
30  Log::info() << "Executing: '" << sql << "'" << std::endl;
31 
32  odc::Select sel(sql);
33  odc::Select::iterator it2 = sel.begin();
34  odc::Select::iterator end2 = sel.end();
35 
36  ASSERT( (*it2)[0] == 55);
37 }
38 
39 static void setUp()
40 {
41  stringstream s;
42  s << "a:REAL" << std::endl;
43  for (size_t i = 1; i <= 10; ++i)
44  s << i << std::endl;
45  FileHandle dh("TestAggregateFunctions3.odb");
46  dh.openForWrite(0);
47  AutoClose close(dh);
48  odc::api::odbFromCSV(s, dh);
49 }
50 
51 
52 static void tearDown(){}
53 
54 SIMPLE_TEST(AggregateFunctions3)
static void tearDown()
static void test()
static void setUp()
#define SIMPLE_TEST(name)
Definition: TestCase.h:66
const iterator end()
Definition: Select.cc:77
iterator begin()
Definition: Select.cc:81
size_t odbFromCSV(DataHandle &dh_in, DataHandle &dh_out, const std::string &delimiter)
odbFromCSV returns number of lines imported
Definition: Odb.cc:375
Definition: ColumnInfo.h:23
Definition: encode.cc:30