Skip to content

Commit

Permalink
Test suite: fix to make it pass with ENABLE_TIFF=OFF (fixes OSGeo#3900)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 28, 2023
1 parent f57c3ff commit ed942ab
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 27 deletions.
11 changes: 7 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,26 @@ endif()
proj_add_gie_test("Builtins" "gie/builtins.gie")
proj_add_gie_test("Builtins2" "gie/more_builtins.gie")
proj_add_gie_test("Axisswap" "gie/axisswap.gie")
proj_add_gie_test("Deformation" "gie/deformation.gie")
proj_add_gie_test("Ellipsoid" "gie/ellipsoid.gie")
proj_add_gie_test("GDA" "gie/GDA.gie")
proj_add_gie_test("4D-API-cs2cs-style" "gie/4D-API_cs2cs-style.gie")
proj_add_gie_test("DHDN_ETRS89" "gie/DHDN_ETRS89.gie")
proj_add_gie_test("Unitconvert" "gie/unitconvert.gie")
proj_add_gie_test("geotiff_grids" "gie/geotiff_grids.gie")
proj_add_gie_test("adams_hemi" "gie/adams_hemi.gie")
proj_add_gie_test("adams_ws1" "gie/adams_ws1.gie")
proj_add_gie_test("adams_ws2" "gie/adams_ws2.gie")
proj_add_gie_test("guyou" "gie/guyou.gie")
proj_add_gie_test("peirce_q" "gie/peirce_q.gie")
proj_add_gie_test("defmodel" "gie/defmodel.gie")
proj_add_gie_test("tinshift" "gie/tinshift.gie")

if(TIFF_ENABLED)
proj_add_gie_test("Deformation" "gie/deformation.gie")
proj_add_gie_test("geotiff_grids" "gie/geotiff_grids.gie")
proj_add_gie_test("defmodel" "gie/defmodel.gie")
proj_add_gie_test("gridshift" "gie/gridshift.gie")
endif()

if(CURL_ENABLED AND RUN_NETWORK_DEPENDENT_TESTS)
if(TIFF_ENABLED AND CURL_ENABLED AND RUN_NETWORK_DEPENDENT_TESTS)
proj_add_gie_network_dependent_test("nkg" "gie/nkg.gie")
endif()

Expand Down
9 changes: 9 additions & 0 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,23 @@ target_link_libraries(proj_test_cpp_api
add_test(NAME proj_test_cpp_api COMMAND proj_test_cpp_api)
set_property(TEST proj_test_cpp_api
PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT})
if(TIFF_ENABLED)
target_compile_definitions(proj_test_cpp_api PRIVATE -DTIFF_ENABLED)
endif()

add_executable(gie_self_tests
main.cpp
gie_self_tests.cpp)
target_link_libraries(gie_self_tests
PRIVATE GTest::gtest
PRIVATE ${PROJ_LIBRARIES})

add_test(NAME gie_self_tests COMMAND gie_self_tests)
set_property(TEST gie_self_tests
PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT})
if(TIFF_ENABLED)
target_compile_definitions(gie_self_tests PRIVATE -DTIFF_ENABLED)
endif()

add_executable(test_network
main.cpp
Expand All @@ -183,9 +190,11 @@ target_link_libraries(test_network
PRIVATE GTest::gtest
PRIVATE ${PROJ_LIBRARIES}
PRIVATE ${SQLITE3_LIBRARY})
if(TIFF_ENABLED)
add_test(NAME test_network COMMAND test_network)
set_property(TEST test_network
PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT})
endif()

add_executable(test_defmodel
main.cpp
Expand Down
2 changes: 2 additions & 0 deletions test/unit/gie_self_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ TEST(gie, info_functions) {

proj_destroy(P);

#ifdef TIFF_ENABLED
/* proj_grid_info() */
grid_info = proj_grid_info("tests/test_hgrid.tif");
ASSERT_NE(std::string(grid_info.filename), "");
Expand All @@ -420,6 +421,7 @@ TEST(gie, info_functions) {
EXPECT_NEAR(grid_info.lowerleft.phi, 0.90757121103705141, 1e-15);
EXPECT_NEAR(grid_info.upperright.lam, 0.12217304763960307, 1e-15);
EXPECT_NEAR(grid_info.upperright.phi, 0.95993108859688125, 1e-15);
#endif

grid_info = proj_grid_info("nonexistinggrid");
ASSERT_EQ(std::string(grid_info.filename), "");
Expand Down
2 changes: 2 additions & 0 deletions test/unit/test_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ TEST_F(CApi, proj_coordoperation_get_grid_used) {

// ---------------------------------------------------------------------------

#ifdef TIFF_ENABLED
TEST_F(CApi, proj_coordoperation_get_grid_used_fullname_caching) {
// Test bugfix for
// https://github.com/OSGeo/PROJ/issues/3444#issuecomment-1309499342
Expand Down Expand Up @@ -1688,6 +1689,7 @@ TEST_F(CApi, proj_coordoperation_get_grid_used_fullname_caching) {
<< std::string(fullName);
}
}
#endif

// ---------------------------------------------------------------------------

Expand Down
50 changes: 27 additions & 23 deletions test/unit/test_grids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,31 @@ TEST_F(GridTest, HorizontalShiftGridSet_null) {

// ---------------------------------------------------------------------------

TEST_F(GridTest, GenericShiftGridSet_null) {
auto gridSet = NS_PROJ::GenericShiftGridSet::open(m_ctxt, "null");
ASSERT_NE(gridSet, nullptr);
auto grid = gridSet->gridAt(0.0, 0.0);
ASSERT_NE(grid, nullptr);
EXPECT_EQ(grid->width(), 3);
EXPECT_EQ(grid->height(), 3);
EXPECT_EQ(grid->extentAndRes().west, -M_PI);
EXPECT_TRUE(grid->isNullGrid());
EXPECT_FALSE(grid->hasChanged());
float out = -1.0f;
EXPECT_TRUE(grid->valueAt(0, 0, 0, out));
EXPECT_EQ(out, 0.0f);
EXPECT_EQ(grid->unit(0), "");
EXPECT_EQ(grid->description(0), "");
EXPECT_EQ(grid->metadataItem("foo"), "");
EXPECT_EQ(grid->samplesPerPixel(), 0);
gridSet->reassign_context(m_ctxt2);
gridSet->reopen(m_ctxt2);
}

#ifdef TIFF_ENABLED

// ---------------------------------------------------------------------------

TEST_F(GridTest, HorizontalShiftGridSet_gtiff) {
auto gridSet =
NS_PROJ::HorizontalShiftGridSet::open(m_ctxt, "tests/test_hgrid.tif");
Expand Down Expand Up @@ -147,29 +172,6 @@ TEST_F(GridTest, HorizontalShiftGridSet_gtiff) {

// ---------------------------------------------------------------------------

TEST_F(GridTest, GenericShiftGridSet_null) {
auto gridSet = NS_PROJ::GenericShiftGridSet::open(m_ctxt, "null");
ASSERT_NE(gridSet, nullptr);
auto grid = gridSet->gridAt(0.0, 0.0);
ASSERT_NE(grid, nullptr);
EXPECT_EQ(grid->width(), 3);
EXPECT_EQ(grid->height(), 3);
EXPECT_EQ(grid->extentAndRes().west, -M_PI);
EXPECT_TRUE(grid->isNullGrid());
EXPECT_FALSE(grid->hasChanged());
float out = -1.0f;
EXPECT_TRUE(grid->valueAt(0, 0, 0, out));
EXPECT_EQ(out, 0.0f);
EXPECT_EQ(grid->unit(0), "");
EXPECT_EQ(grid->description(0), "");
EXPECT_EQ(grid->metadataItem("foo"), "");
EXPECT_EQ(grid->samplesPerPixel(), 0);
gridSet->reassign_context(m_ctxt2);
gridSet->reopen(m_ctxt2);
}

// ---------------------------------------------------------------------------

TEST_F(GridTest, GenericShiftGridSet_gtiff) {
ASSERT_EQ(NS_PROJ::GenericShiftGridSet::open(m_ctxt, "foobar"), nullptr);
auto gridSet = NS_PROJ::GenericShiftGridSet::open(
Expand Down Expand Up @@ -335,4 +337,6 @@ TEST_F(GridTest, GenericShiftGridSet_gtiff_projected) {
EXPECT_EQ(grid->extentAndRes().resY, 1000);
}

#endif // TIFF_ENABLED

} // namespace

0 comments on commit ed942ab

Please sign in to comment.