-
Notifications
You must be signed in to change notification settings - Fork 48
/
test_gdal_netcdf.cpp
67 lines (52 loc) · 1.67 KB
/
test_gdal_netcdf.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
MDAL - Mesh Data Abstraction Library (MIT License)
Copyright (C) 2018 Peter Petrik (zilolv at gmail dot com)
*/
#include "gtest/gtest.h"
#include <string>
#include <vector>
//mdal
#include "mdal.h"
#include "mdal_testutils.hpp"
TEST( MeshGdalNetCDFTest, Indonesia )
{
std::vector<std::string> files;
files.push_back( "indonesia_nc3.nc" );
files.push_back( "indonesia_nc4.nc" );
for ( const std::string &file : files )
{
std::string path = test_file( std::string( "/netcdf/" ) + file );
MeshH m = MDAL_LoadMesh( path.c_str() );
ASSERT_NE( m, nullptr );
MDAL_Status s = MDAL_LastStatus();
EXPECT_EQ( MDAL_Status::None, s );
ASSERT_EQ( 2, MDAL_M_datasetGroupCount( m ) );
DatasetGroupH g = MDAL_M_datasetGroup( m, 1 );
ASSERT_NE( g, nullptr );
int meta_count = MDAL_G_metadataCount( g );
ASSERT_EQ( 1, meta_count );
const char *name = MDAL_G_name( g );
EXPECT_EQ( std::string( "Total cloud cover" ), std::string( name ) );
bool scalar = MDAL_G_hasScalarData( g );
EXPECT_EQ( true, scalar );
bool onVertices = MDAL_G_isOnVertices( g );
EXPECT_EQ( true, onVertices );
ASSERT_EQ( 31, MDAL_G_datasetCount( g ) );
DatasetH ds = MDAL_G_dataset( g, 10 );
ASSERT_NE( ds, nullptr );
bool valid = MDAL_D_isValid( ds );
EXPECT_EQ( true, valid );
bool active = MDAL_D_active( ds, 50 );
EXPECT_EQ( true, active );
int count = MDAL_D_valueCount( ds );
ASSERT_EQ( 234, count );
double value = MDAL_D_value( ds, 50 );
EXPECT_DOUBLE_EQ( 32759, value );
MDAL_CloseMesh( m );
}
}
int main( int argc, char **argv )
{
testing::InitGoogleTest( &argc, argv );
return RUN_ALL_TESTS();
}