From ecf8aef9ede4361c887c9b2169fdc8906e58223c Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 4 Nov 2023 22:19:23 +0100 Subject: [PATCH] Reformat and add test case --- src/iso19111/factory.cpp | 4 ++-- test/unit/test_factory.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 35b4e9f463..719558018f 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -5038,8 +5038,8 @@ AuthorityFactory::createGeodeticCRS(const std::string &code) const { crs::GeographicCRSNNPtr AuthorityFactory::createGeographicCRS(const std::string &code) const { auto crs(util::nn_dynamic_pointer_cast( - createGeodeticCRS(code, true))); - if(!crs) { + createGeodeticCRS(code, true))); + if (!crs) { throw NoSuchAuthorityCodeException("geographicCRS not found", d->authority(), code); } diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp index 1b261945e7..000ba71e05 100644 --- a/test/unit/test_factory.cpp +++ b/test/unit/test_factory.cpp @@ -596,6 +596,18 @@ TEST(factory, AuthorityFactory_createGeodeticCRS_geocentric) { // --------------------------------------------------------------------------- +TEST(factory, AuthorityFactory_createGeographicCRS) { + auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto crs = factory->createGeographicCRS("4979"); + ASSERT_TRUE(nn_dynamic_pointer_cast(crs) != nullptr); + ASSERT_EQ(crs->identifiers().size(), 1U); + EXPECT_EQ(crs->identifiers()[0]->code(), "4979"); + + EXPECT_THROW(factory->createGeographicCRS("4978"), FactoryException); +} + +// --------------------------------------------------------------------------- + TEST(factory, AuthorityFactory_createVerticalCRS) { auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); EXPECT_THROW(factory->createVerticalCRS("-1"),