From e4e2991b174ea48b67e9b41c8f356a9cf1bba081 Mon Sep 17 00:00:00 2001 From: "Alan D. Snow" Date: Sun, 18 Apr 2021 05:34:29 -0500 Subject: Added proj_get_celestial_body_list_from_database (#2674) Closes #2667 --- test/unit/test_c_api.cpp | 31 +++++++++++++++++++++++++++++++ test/unit/test_factory.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'test') diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index ca41620e..964d25d9 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -3899,6 +3899,37 @@ TEST_F(CApi, proj_get_units_from_database) { // --------------------------------------------------------------------------- +TEST_F(CApi, proj_get_celestial_body_list_from_database) { + { proj_celestial_body_list_destroy(nullptr); } + + { + auto list = proj_get_celestial_body_list_from_database(nullptr, nullptr, 0); + ASSERT_NE(list, nullptr); + ASSERT_NE(list[0], nullptr); + ASSERT_NE(list[0]->auth_name, nullptr); + ASSERT_NE(list[0]->name, nullptr); + proj_celestial_body_list_destroy(list); + } + { + int result_count = 0; + auto list = proj_get_celestial_body_list_from_database(nullptr, "ESRI", &result_count); + ASSERT_NE(list, nullptr); + EXPECT_GT(result_count, 1); + EXPECT_EQ(list[result_count], nullptr); + bool foundGanymede = false; + for (int i = 0; i < result_count; i++) { + EXPECT_EQ(std::string(list[i]->auth_name), "ESRI"); + if (std::string(list[i]->name) == "Ganymede") { + foundGanymede = true; + } + } + EXPECT_TRUE(foundGanymede); + proj_celestial_body_list_destroy(list); + } +} + +// --------------------------------------------------------------------------- + TEST_F(CApi, proj_normalize_for_visualization) { { diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp index edc8b190..02033a8a 100644 --- a/test/unit/test_factory.cpp +++ b/test/unit/test_factory.cpp @@ -3441,6 +3441,39 @@ TEST(factory, getUnitList) { // --------------------------------------------------------------------------- +TEST(factory, getCelestialBodyList) { + auto ctxt = DatabaseContext::create(); + { + auto factory = AuthorityFactory::create(ctxt, std::string()); + auto list = factory->getCelestialBodyList(); + EXPECT_GT(list.size(), 1U); + bool foundPROJ = false; + bool foundESRI = false; + bool foundEarth = false; + for (const auto &info : list) { + foundESRI |= info.authName == "ESRI"; + foundPROJ |= info.authName == "PROJ"; + if (info.authName == "PROJ") { + EXPECT_EQ(info.name, "Earth"); + foundEarth = true; + } + } + EXPECT_TRUE(foundESRI); + EXPECT_TRUE(foundPROJ); + EXPECT_TRUE(foundEarth); + } + { + auto factory = AuthorityFactory::create(ctxt, "ESRI"); + auto list = factory->getCelestialBodyList(); + EXPECT_GT(list.size(), 1U); + for (const auto &info : list) { + EXPECT_EQ(info.authName, "ESRI"); + } + } +} + +// --------------------------------------------------------------------------- + TEST(factory, objectInsertion) { // Cannot nest startInsertStatementsSession -- cgit v1.2.3