IODA Bundle
TestFunctionDotp.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 = 4e-5;
16 
17 #include <cmath>
18 
19 #include "eckit/log/Timer.h"
20 #include "odc/Select.h"
21 
22 #include "odc/Writer.h"
23 #include "TestCase.h"
24 
25 using namespace std;
26 using namespace eckit;
27 using namespace odc;
28 
29 
30 
31 static void setUp()
32 {
33  Timer t("Test Dotp function");
34  odc::Writer<> oda("test_dotp.odb");
35 
36  odc::Writer<>::iterator row = oda.begin();
37  row->setNumberOfColumns(2);
38 
39  row->setColumn(0, "x", odc::api::REAL);
40  row->setColumn(1, "y", odc::api::REAL);
41 
42  row->writeHeader();
43 
44  (*row)[0] = 3.0;
45  (*row)[1] = 2.0;
46  ++row;
47  (*row)[0] = 7.5;
48  (*row)[1] = 112.0;
49  ++row;
50  (*row)[0] = 93.7;
51  (*row)[1] = 12.3;
52  ++row;
53 }
54 
55 static void tearDown()
56 {
57  PathName("test_dotp.odb").unlink();
58 }
59 
60 static void test()
61 {
62  const string sql = "select dotp(x,y) from \"test_dotp.odb\";";
63 
64  Log::info() << "Executing: '" << sql << "'" << std::endl;
65 
66  odc::Select oda(sql);
67  odc::Select::iterator it = oda.begin();
68 
69  ASSERT(fabs((*it)[0] - 1998.51e0)<EPS); //
70 
71 }
72 
73 
74 
75 SIMPLE_TEST(FunctionDotp)
void oda
#define SIMPLE_TEST(name)
Definition: TestCase.h:66
static void tearDown()
static void test()
static void setUp()
const double EPS
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