Commit 5a8c55dd authored by Purves, Murray's avatar Purves, Murray
Browse files

WIP testing next section

parent 5dc70502
Pipeline #16597 failed with stages
in 16 minutes and 13 seconds
......@@ -106,6 +106,7 @@ bool ARLDataStream::read_next_index_header(ARLIndexHeader& iheader)
{
int bytesToSkip = roundUpInt(p->stream->bytesRead(), p->recordSize) -
p->stream->bytesRead();
radix_line("Skipping " << bytesToSkip << " bytes to the next index header");
p->stream->skipBytes(bytesToSkip);
......@@ -135,6 +136,7 @@ bool ARLDataStream::read_record(const ARLIndexHeader& iheader,
std::vector<std::vector<double> >& record)
{
// Set up the vector size
record.clear();
record.resize(rheader.nx);
for (std::vector<double>& vec : record)
{
......
......@@ -6,8 +6,10 @@
using namespace radix;
TEST(RadixIO, ReadArlStream)
TEST(RadixIO, ReadArlElements)
{
double tolerance = 0.001;
std::string testFile = "/home/ohp/data/met/RP195111.gbl";
ARLDataStream testStream(testFile);
......@@ -44,4 +46,46 @@ TEST(RadixIO, ReadArlStream)
std::vector<std::vector<double>> testRecord;
success =
testStream.read_record(testIndexHeader, testRecordHeader, testRecord);
// Test content
ASSERT_TRUE(success);
ASSERT_EQ(testRecordHeader.nx, testRecord.size());
ASSERT_EQ(testRecordHeader.ny, testRecord[0].size());
EXPECT_NEAR(665.9, testRecord[0][0], 665.9 * tolerance);
EXPECT_NEAR(665.9, testRecord[1][0], 665.9 * tolerance);
EXPECT_NEAR(677.9, testRecord[0][1], 677.9 * tolerance);
EXPECT_NEAR(677.9, testRecord[1][1], 677.9 * tolerance);
EXPECT_NEAR(1013.9, testRecord[142][71], 1013.9 * tolerance);
EXPECT_NEAR(1011.9, testRecord[143][71], 1011.9 * tolerance);
EXPECT_NEAR(1015.9, testRecord[142][72], 1015.9 * tolerance);
EXPECT_NEAR(1015.9, testRecord[143][72], 1015.9 * tolerance);
// Try another one
success = testStream.read_next_index_header(testIndexHeader);
ASSERT_TRUE(success);
// Test the content
EXPECT_EQ(51, testIndexHeader.year);
EXPECT_EQ(11, testIndexHeader.month);
EXPECT_EQ(1, testIndexHeader.day);
EXPECT_EQ(0, testIndexHeader.hour);
EXPECT_STREQ("T02M", testIndexHeader.kvar.c_str());
// Read data
success =
testStream.read_record(testIndexHeader, testRecordHeader, testRecord);
// Test content
ASSERT_TRUE(success);
ASSERT_EQ(testRecordHeader.nx, testRecord.size());
ASSERT_EQ(testRecordHeader.ny, testRecord[0].size());
EXPECT_NEAR(233.4, testRecord[0][0], 233.4 * tolerance);
EXPECT_NEAR(233.4, testRecord[1][0], 233.4 * tolerance);
EXPECT_NEAR(227.1, testRecord[0][1], 227.1 * tolerance);
EXPECT_NEAR(227.1, testRecord[1][1], 227.1 * tolerance);
EXPECT_NEAR(236.0, testRecord[142][71], 236.0 * tolerance);
EXPECT_NEAR(236.1, testRecord[143][71], 236.1 * tolerance);
EXPECT_NEAR(240.6, testRecord[142][72], 240.6 * tolerance);
EXPECT_NEAR(240.6, testRecord[143][72], 240.6 * tolerance);
}
// TEST(RadixIO, ReadArlWholeFile)
//{
//}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment