-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
E57Simple: Fix min/max fields in Data3D (#153)
There was a mixture of using float and double min/max. When using float, they should be set to E57_FLOAT_MIN and E57_FLOAT_MAX. When using double, they should be set to E57_DOUBLE_MIN and E57_DOUBLE_MAX. Do this adjustment to Data3D automatically in the Data3DPointsData_t() constructor and add tests for it.
- Loading branch information
Showing
4 changed files
with
101 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// libE57Format testing Copyright © 2022 Andy Maloney <asmaloney@gmail.com> | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "E57SimpleData.h" | ||
|
||
#include "Helpers.h" | ||
|
||
TEST( SimpleDataH, InvalidPointSize ) | ||
{ | ||
e57::Data3D dataHeader; | ||
|
||
E57_ASSERT_THROW( e57::Data3DPointsData pointsData( dataHeader ) ); | ||
} | ||
|
||
TEST( SimpleDataH, HeaderMinMaxFloat ) | ||
{ | ||
e57::Data3D dataHeader; | ||
|
||
dataHeader.pointsSize = 1; | ||
|
||
EXPECT_EQ( dataHeader.pointFields.pointRangeMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.pointRangeMaximum, e57::E57_DOUBLE_MAX ); | ||
EXPECT_EQ( dataHeader.pointFields.angleMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.angleMaximum, e57::E57_DOUBLE_MAX ); | ||
EXPECT_EQ( dataHeader.pointFields.timeMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.timeMaximum, e57::E57_DOUBLE_MAX ); | ||
|
||
// This call should adjust our min/max for a variety of fields since we are using floats. | ||
e57::Data3DPointsData pointsData( dataHeader ); | ||
|
||
EXPECT_EQ( dataHeader.pointFields.pointRangeMinimum, e57::E57_FLOAT_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.pointRangeMaximum, e57::E57_FLOAT_MAX ); | ||
EXPECT_EQ( dataHeader.pointFields.angleMinimum, e57::E57_FLOAT_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.angleMaximum, e57::E57_FLOAT_MAX ); | ||
EXPECT_EQ( dataHeader.pointFields.timeMinimum, e57::E57_FLOAT_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.timeMaximum, e57::E57_FLOAT_MAX ); | ||
} | ||
|
||
TEST( SimpleDataH, HeaderMinMaxDouble ) | ||
{ | ||
e57::Data3D dataHeader; | ||
|
||
dataHeader.pointsSize = 1; | ||
|
||
EXPECT_EQ( dataHeader.pointFields.pointRangeMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.pointRangeMaximum, e57::E57_DOUBLE_MAX ); | ||
EXPECT_EQ( dataHeader.pointFields.angleMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.angleMaximum, e57::E57_DOUBLE_MAX ); | ||
EXPECT_EQ( dataHeader.pointFields.timeMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.timeMaximum, e57::E57_DOUBLE_MAX ); | ||
|
||
// This call should NOT adjust our min/max for a variety of fields since we are using doubles. | ||
e57::Data3DPointsData_d pointsData( dataHeader ); | ||
|
||
EXPECT_EQ( dataHeader.pointFields.pointRangeMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.pointRangeMaximum, e57::E57_DOUBLE_MAX ); | ||
EXPECT_EQ( dataHeader.pointFields.angleMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.angleMaximum, e57::E57_DOUBLE_MAX ); | ||
EXPECT_EQ( dataHeader.pointFields.timeMinimum, e57::E57_DOUBLE_MIN ); | ||
EXPECT_EQ( dataHeader.pointFields.timeMaximum, e57::E57_DOUBLE_MAX ); | ||
} |