IODA Bundle
TestDispatchingWriter.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.h
12 ///
13 /// @author Piotr Kuchta, ECMWF, June 2009
14 
15 #include "odc/DispatchingWriter.h"
16 #include "odc/Reader.h"
17 #include "odc/StringTool.h"
18 
19 #include "TestCase.h"
20 #include "CountTool.h"
21 
22 using namespace std;
23 using namespace eckit;
24 using namespace odc;
25 
26 /// UnitTest DispatchingWriter
27 ///
28 static void test()
29 {
30  const string fileName = "2000010106.odb";
31 
32  odc::Reader oda(fileName);
33  odc::Reader::iterator it = oda.begin();
34  const odc::Reader::iterator end = oda.end();
35  ASSERT(it->columns().size() > 0);
36 
37  odc::DispatchingWriter writer("disp.{obstype}.{sensor}.odb");
39  unsigned long long n1 = wi->pass1(it, end);
40  wi->close();
41 
42  unsigned long long sum = 0;
43  vector<PathName> files = (**wi).outputFiles();
44  for (size_t i = 0; i < files.size(); ++i)
45  {
46  unsigned long long n = odc::tool::CountTool::rowCount(files[i]);
47  Log::info() << i << ". " << files[i] << ": " << n << std::endl;
48  sum += n;
49  }
50 
51  ASSERT(n1 == sum);
52  odc::StringTool::shell("ls -l disp.*.*.odb", Here());
53 }
54 
55 
56 static void setUp(){}
57 static void tearDown(){}
58 
void oda
#define SIMPLE_TEST(name)
Definition: TestCase.h:66
static void tearDown()
static void test()
static void setUp()
unsigned long pass1(T b, const T e)
const core::MetaData & columns() const
Definition: IteratorProxy.h:94
void close()
static int shell(std::string cmd, const eckit::CodeLocation &where, bool assertSuccess=true)
Definition: StringTool.cc:64
static size_t rowCount(const eckit::PathName &)
Definition: CountTool.cc:24
Definition: ColumnInfo.h:23
Definition: encode.cc:30