diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f41f664ce6..9ec53dc567 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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() diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 1ec1dcb892..e58b11931a 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -154,6 +154,9 @@ 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 @@ -161,9 +164,13 @@ add_executable(gie_self_tests 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 @@ -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 diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp index b8ab1da233..646e1cb718 100644 --- a/test/unit/gie_self_tests.cpp +++ b/test/unit/gie_self_tests.cpp @@ -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), ""); @@ -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), ""); diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 6862f03b2d..18fbd1feab 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -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 @@ -1688,6 +1689,7 @@ TEST_F(CApi, proj_coordoperation_get_grid_used_fullname_caching) { << std::string(fullName); } } +#endif // --------------------------------------------------------------------------- diff --git a/test/unit/test_grids.cpp b/test/unit/test_grids.cpp index 29dd080c24..3eab20feff 100644 --- a/test/unit/test_grids.cpp +++ b/test/unit/test_grids.cpp @@ -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"); @@ -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( @@ -335,4 +337,6 @@ TEST_F(GridTest, GenericShiftGridSet_gtiff_projected) { EXPECT_EQ(grid->extentAndRes().resY, 1000); } +#endif // TIFF_ENABLED + } // namespace