Skip to content

Commit

Permalink
Merge branch 'develop' - v0.4.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
GPMueller committed Feb 20, 2019
2 parents 36d70b5 + 107240e commit 70ccca3
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set( META_AUTHOR_MAINTAINER "Gideon Mueller" )
set( META_AUTHOR_EMAIL "g.mueller@fz-juelich.de" )
set( META_VERSION_MAJOR "0" )
set( META_VERSION_MINOR "4" )
set( META_VERSION_PATCH "0" )
set( META_VERSION_PATCH "1" )
set( META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}" )
#############################################

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ Current limitations of this library
- not all defaults in the segment are guaranteed to be sensible
- `valueunits` and `valuelabels` are written and parsed, but not checked for dimensionality or content in either
- `min` and `max` values are not checked to make sure they are sensible bounds
- `irregular` mesh type is not supported properly, as positions are not accounted for in read or write


Example
Expand Down
6 changes: 4 additions & 2 deletions include/ovf.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#ifndef LIBOVF_H
#define LIBOVF_H

#include <stdbool.h>

// Platform-specific definition of DLLEXPORT
#ifdef _WIN32
#ifdef __cplusplus
Expand Down Expand Up @@ -66,9 +68,9 @@ struct ovf_file {
int version;

/* file could be found */
int found;
bool found;
/* file contains an ovf header */
int is_ovf;
bool is_ovf;
/* number of segments the file should contain */
int n_segments;

Expand Down
14 changes: 12 additions & 2 deletions python/test/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def test_nonexistent(self):
with ovf.ovf_file("nonexistent.ovf") as ovf_file:
print("found: ", ovf_file.found)
print("is_ovf: ", ovf_file.is_ovf)
print("version: ", ovf_file.version)
print("n_segments: ", ovf_file.n_segments)
self.assertTrue( ovf_file.found == False )
self.assertTrue( ovf_file.is_ovf == False )
self.assertTrue( ovf_file.version == 0 )
self.assertTrue( ovf_file.n_segments == 0 )
segment = ovf.ovf_segment()
success = ovf_file.read_segment_header(0, segment)
if success != ovf.OK:
Expand All @@ -34,8 +39,8 @@ def test_write(self):
segment = ovf.ovf_segment(
title="python write test",
comment="more details in this comment...",
n_cells=[2,2,1],
valuedim=3)
valuedim=3,
n_cells=[2,2,1])
success = ovf_file.write_segment(segment, data)
if success != ovf.OK:
print("write_segment failed: ", ovf_file.get_latest_message())
Expand All @@ -52,7 +57,12 @@ def test_write(self):
with ovf.ovf_file("testfile_py.ovf") as ovf_file:
print("found: ", ovf_file.found)
print("is_ovf: ", ovf_file.is_ovf)
print("version: ", ovf_file.version)
print("n_segments: ", ovf_file.n_segments)
self.assertTrue( ovf_file.found == True )
self.assertTrue( ovf_file.is_ovf == True )
self.assertTrue( ovf_file.version == 2 )
self.assertTrue( ovf_file.n_segments == 2 )
segment = ovf.ovf_segment()
success = ovf_file.read_segment_header(0, segment)
if success != ovf.OK:
Expand Down
8 changes: 7 additions & 1 deletion src/ovf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ struct ovf_file* ovf_open(const char *filename)
try
{
// Initialize the struct
struct ovf_file * ovf_file_ptr = new ovf_file{ strdup(filename), /*version*/ 0, /*found*/ false, /*ovf*/ false, /*n_segments*/ 0, /*handle*/ new parser_state };
struct ovf_file * ovf_file_ptr = new ovf_file{
/*file_name*/ strdup(filename),
/*version*/ 0,
/*found*/ false,
/*is_ovf*/ false,
/*n_segments*/ 0,
/*handle*/ new parser_state };

// Check if the file exists
std::fstream filestream( filename );
Expand Down
23 changes: 14 additions & 9 deletions test/simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
TEST_CASE( "NonExistent", "[nonexistent]" )
{
auto file = ovf_open("nonexistent.ovf");
REQUIRE( file->found == false );
REQUIRE( file->is_ovf == false );
REQUIRE( file->n_segments == 0 );
ovf_segment segment;
int success = ovf_read_segment_header(file, 0, &segment);
REQUIRE( success == OVF_ERROR );
Expand Down Expand Up @@ -118,14 +121,16 @@ TEST_CASE( "Read", "[read]" )

SECTION( "first segment" )
{
// segment header
auto segment = ovf_segment_initialize();

// open
auto file = ovf_open(testfile);
REQUIRE( file->found == true );
REQUIRE( file->is_ovf == true );
REQUIRE( file->n_segments == 3 );
int index = 0;

// segment header
auto segment = ovf_segment_initialize();

// read header
int success = ovf_read_segment_header(file, index, segment);
if( OVF_OK != success )
Expand Down Expand Up @@ -154,14 +159,14 @@ TEST_CASE( "Read", "[read]" )

SECTION( "second segment" )
{
// segment header
auto segment = ovf_segment_initialize();

// open
auto file = ovf_open(testfile);
REQUIRE( file->n_segments == 3 );
int index = 1;

// segment header
auto segment = ovf_segment_initialize();

// read header
int success = ovf_read_segment_header(file, index, segment);
if( OVF_OK != success )
Expand Down Expand Up @@ -190,14 +195,14 @@ TEST_CASE( "Read", "[read]" )

SECTION( "third segment" )
{
// segment header
auto segment = ovf_segment_initialize();

// open
auto file = ovf_open(testfile);
REQUIRE( file->n_segments == 3 );
int index = 2;

// segment header
auto segment = ovf_segment_initialize();

// read header
int success = ovf_read_segment_header(file, index, segment);
if( OVF_OK != success )
Expand Down

0 comments on commit 70ccca3

Please sign in to comment.