IODA Bundle
TestIntegerValues.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 TestIntegerValues.h
12
///
13
/// @author Piotr Kuchta, ECMWF, Jan 2011
14
15
#include "eckit/filesystem/PathName.h"
16
#include "eckit/io/FileHandle.h"
17
18
#include "
odc/Reader.h
"
19
#include "
odc/api/Odb.h
"
20
21
22
#include "
TestCase.h
"
23
24
25
26
27
28
using namespace
std
;
29
using namespace
eckit
;
30
using namespace
odc
;
31
32
static
void
setUp
()
33
{
34
const
char
* data =
35
"date:REAL\n"
36
"20101130\n"
37
"20101201\n"
38
"20101202\n"
;
39
FileHandle dh(
"TestIntegerValues.odb"
);
40
dh.openForWrite(0);
41
AutoClose close(dh);
42
odc::api::odbFromCSV
(data, dh);
43
}
44
45
46
static
void
test
()
47
{
48
//Log::info() << fixed;
49
////////////////////////////// ODB from MARS //////////////////////////////
50
51
const
std::string fileNameOdb=
"TestIntegerValues.odb"
;
52
53
odc::Reader
odb(fileNameOdb);
54
odc::Reader::iterator
it = odb.
begin
();
55
56
for
(
unsigned
int
i
=0;
i
< it->
columns
().size(); ++
i
) {
57
std::cout <<
"Name = "
<< it->
columns
()[
i
]->name() <<
" "
;
58
}
59
60
std::cout << std::endl;
61
int
nrows=0;
62
for
(; it != odb.
end
(); ++it)
63
{
64
++nrows;
65
for
(
size_t
i
=0;
i
< it->
columns
().size(); ++
i
)
66
{
67
//float nr = ((*it)[i]); /// <- WRONG!
68
double
nr = ((*it)[
i
]);
69
switch
(it->
columns
()[
i
]->type())
70
{
71
case
odc::api::INTEGER
:
72
case
odc::api::BITFIELD
:
73
std::cout << static_cast<int>(nr) <<
" "
;
74
//cout << "* should be: " << it->integer(i) << " ";
75
break
;
76
case
odc::api::REAL
:
77
std::cout << nr <<
" "
;
78
break
;
79
case
odc::api::IGNORE
:
80
default
:
81
ASSERT(
"Unknown type"
&&
false
);
82
break
;
83
}
84
}
85
std::cout << std::endl;
86
}
87
}
88
89
static
void
tearDown
() { }
90
91
92
SIMPLE_TEST
(IntegerValues)
Odb.h
Reader.h
TestCase.h
SIMPLE_TEST
#define SIMPLE_TEST(name)
Definition:
TestCase.h:66
tearDown
static void tearDown()
Definition:
TestIntegerValues.cc:89
test
static void test()
Definition:
TestIntegerValues.cc:46
setUp
static void setUp()
Definition:
TestIntegerValues.cc:32
odc::IteratorProxy
Definition:
IteratorProxy.h:123
odc::Reader
Definition:
Reader.h:32
odc::Reader::end
const iterator end() const
Definition:
Reader.cc:81
odc::Reader::begin
iterator begin()
Definition:
Reader.cc:74
odc::Row_::columns
const core::MetaData & columns() const
Definition:
IteratorProxy.h:94
eckit
Definition:
DistributionUtils.h:15
odc::api::odbFromCSV
size_t odbFromCSV(DataHandle &dh_in, DataHandle &dh_out, const std::string &delimiter)
odbFromCSV returns number of lines imported
Definition:
Odb.cc:375
odc::api::INTEGER
@ INTEGER
Definition:
ColumnType.h:24
odc::api::REAL
@ REAL
Definition:
ColumnType.h:25
odc::api::IGNORE
@ IGNORE
Definition:
ColumnType.h:23
odc::api::BITFIELD
@ BITFIELD
Definition:
ColumnType.h:27
odc
Definition:
ColumnInfo.h:23
proc_gsi_ncdiag.i
i
Definition:
proc_gsi_ncdiag.py:155
std
Definition:
encode.cc:30
odc
src
odc
tools
TestIntegerValues.cc
Generated on Fri Aug 20 2021 11:49:12 for IODA Bundle by
1.9.1