IODA Bundle
test_metadata.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 #include <memory>
12 
13 #include "eckit/testing/Test.h"
14 
15 #include "odc/core/MetaData.h"
16 #include "odc/Writer.h"
17 
18 using namespace eckit::testing;
19 using eckit::Log;
20 
21 // ------------------------------------------------------------------------------------------------------
22 
23 CASE("Copy metadata preserves data sizes") {
24 
26  md.addColumn("col1", "STRING");
27  md.back()->dataSizeDoubles(2);
28  md.addColumn("col2", "STRING");
29 
30  EXPECT(md[0]->dataSizeDoubles() == 2);
31 
33  md2 = md;
34 
35  EXPECT(md.size() == 2);
36  EXPECT(md[0]->dataSizeDoubles() == 2);
37  EXPECT(md[1]->dataSizeDoubles() == 1);
38 }
39 
40 
41 CASE("Copy metadata in Writer") {
42 
44  md.addColumn("col1", "STRING");
45  md.back()->dataSizeDoubles(2);
46  md.addColumn("col2", "STRING");
47 
48  EXPECT(md[0]->dataSizeDoubles() == 2);
49 
50  odc::Writer<> w("example.odb");
52 
53  it->columns(md);
54 
55  eckit::Log::info() << "Found: " << it->columns().at(0)->dataSizeDoubles() << std::endl;
56  EXPECT(it->columns().at(0)->dataSizeDoubles() == 2);
57  EXPECT(it->columns().at(1)->dataSizeDoubles() == 1);
58 }
59 
60 // ------------------------------------------------------------------------------------------------------
61 
62 int main(int argc, char* argv[]) {
63  return run_tests(argc, argv);
64 }
65 
const core::MetaData & columns() const
Definition: IteratorProxy.h:94
iterator begin(bool openDataHandle=true)
Definition: Writer.cc:92
MetaData & addColumn(const std::string &name, const std::string &type)
Definition: MetaData.cc:279
int main(int argc, char *argv[])
CASE("Copy metadata preserves data sizes")