diff options
| author | Alan D. Snow <alansnow21@gmail.com> | 2020-08-20 10:48:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-20 17:48:40 +0200 |
| commit | bc1dcf2cd581a5c144a9c35028bd33aa9191882f (patch) | |
| tree | fede8e9f75fe796ab51c624ade530938bd28a6e2 /test | |
| parent | 2b3475c853b37b1485e92ef8cf78b02fb0db6142 (diff) | |
| download | PROJ-bc1dcf2cd581a5c144a9c35028bd33aa9191882f.tar.gz PROJ-bc1dcf2cd581a5c144a9c35028bd33aa9191882f.zip | |
projCtx_t: Copy ini file settings, proj4_init_rules, etc.. when initializing context from global (#2331)
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/test_c_api.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 9fe486b7..947b993c 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -4797,6 +4797,51 @@ TEST_F(CApi, proj_context_set_sqlite3_vfs_name) { // --------------------------------------------------------------------------- +TEST_F(CApi, proj_context_set_sqlite3_vfs_name__from_global_context) { + + // Set a dummy VFS and check it is taken into account + // (failure to open proj.db) + proj_context_set_sqlite3_vfs_name(nullptr, "dummy_vfs_name"); + + PJ_CONTEXT *ctx = proj_context_create(); + proj_log_func(ctx, nullptr, [](void *, int, const char *) -> void {}); + + ASSERT_EQ(proj_create(ctx, "EPSG:4326"), nullptr); + + // Restore default VFS + proj_context_set_sqlite3_vfs_name(nullptr, nullptr); + proj_context_destroy(ctx); +} + +// --------------------------------------------------------------------------- + +TEST_F(CApi, use_proj4_init_rules) { + PJ_CONTEXT *ctx = proj_context_create(); + proj_context_use_proj4_init_rules(ctx, true); + ASSERT_TRUE(proj_context_get_use_proj4_init_rules(ctx, true)); + proj_context_use_proj4_init_rules(ctx, false); + ASSERT_TRUE(!proj_context_get_use_proj4_init_rules(ctx, true)); + proj_context_destroy(ctx); +} + +// --------------------------------------------------------------------------- + +TEST_F(CApi, use_proj4_init_rules_from_global_context) { + + int initial_rules = proj_context_get_use_proj4_init_rules(nullptr, true); + proj_context_use_proj4_init_rules(nullptr, true); + PJ_CONTEXT *ctx = proj_context_create(); + ASSERT_TRUE(proj_context_get_use_proj4_init_rules(ctx, true)); + proj_context_destroy(ctx); + proj_context_use_proj4_init_rules(nullptr, false); + ctx = proj_context_create(); + ASSERT_TRUE(!proj_context_get_use_proj4_init_rules(ctx, true)); + proj_context_destroy(ctx); + proj_context_use_proj4_init_rules(nullptr, initial_rules); +} + +// --------------------------------------------------------------------------- + TEST_F(CApi, proj_is_equivalent_to_with_ctx) { auto from_epsg = proj_create_from_database(m_ctxt, "EPSG", "7844", PJ_CATEGORY_CRS, false, nullptr); |
