IODA Bundle
TestFunctionTdiff.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.cc
12 ///
13 /// @author ECMWF, July 2010
14 
15 //const double EPS = 7e-6
16 
17 #include "eckit/log/Timer.h"
18 #include "odc/Select.h"
19 
20 #include "odc/Writer.h"
21 #include "TestCase.h"
22 
23 using namespace std;
24 using namespace eckit;
25 using namespace odc;
26 
27 
28 
29 static void setUp()
30 {
31  Timer t("Test tdiff function");
32  odc::Writer<> oda("test_tdiff.odb");
33 
34  odc::Writer<>::iterator row = oda.begin();
35  row->setNumberOfColumns(2);
36 
37  row->setColumn(0, "date", odc::api::INTEGER);
38  row->setColumn(1, "time", odc::api::INTEGER);
39 
40  row->writeHeader();
41 
42  (*row)[0] = 20090706.0;
43  (*row)[1] = 210109.0;
44 
45  ++row;
46 }
47 
48 static void tearDown()
49 {
50  PathName("test_tdiff.odb").unlink();
51 }
52 
53 static void test()
54 {
55  const string sql = "select tdiff(date,time,20090707.0,0.0) from \"test_tdiff.odb\";";
56 
57  Log::info() << "Executing: '" << sql << "'" << std::endl;
58 
59  odc::Select oda(sql);
60  odc::Select::iterator it = oda.begin();
61 
62  ASSERT((*it)[0] == -10731); //
63 
64 }
65 
66 
67 
68 SIMPLE_TEST(FunctionTdiff)
void oda
#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
int setColumn(size_t index, const std::string &name, api::ColumnType type)
Definition: ColumnInfo.h:23
Definition: encode.cc:30