| 89 | // --------------------------------------------------------------------------- |
| 90 | |
| 91 | TEST(proj_context, proj_context_set_file_finder) { |
| 92 | |
| 93 | std::string dirname; |
| 94 | auto filename = createTempDict(dirname, "temp_proj_dic1"); |
| 95 | if (filename.empty()) |
| 96 | return; |
| 97 | |
| 98 | auto ctx = proj_context_create(); |
| 99 | |
| 100 | struct FinderData { |
| 101 | PJ_CONTEXT *got_ctx = nullptr; |
| 102 | std::string dirname{}; |
| 103 | std::string tmpFilename{}; |
| 104 | }; |
| 105 | |
| 106 | const auto finder = [](PJ_CONTEXT *got_ctx, const char *file, |
| 107 | void *user_data) -> const char * { |
| 108 | auto finderData = static_cast<FinderData *>(user_data); |
| 109 | finderData->got_ctx = got_ctx; |
| 110 | finderData->tmpFilename = finderData->dirname; |
| 111 | finderData->tmpFilename += DIR_CHAR; |
| 112 | finderData->tmpFilename += file; |
| 113 | return finderData->tmpFilename.c_str(); |
| 114 | }; |
| 115 | |
| 116 | FinderData finderData; |
| 117 | finderData.dirname = dirname; |
| 118 | proj_context_set_file_finder(ctx, finder, &finderData); |
| 119 | |
| 120 | auto P = proj_create(ctx, "+init=temp_proj_dic1:MY_PIPELINE"); |
| 121 | EXPECT_NE(P, nullptr); |
| 122 | proj_destroy(P); |
| 123 | |
| 124 | EXPECT_EQ(finderData.got_ctx, ctx); |
| 125 | |
| 126 | proj_context_destroy(ctx); |
| 127 | } |
| 128 | |
| 129 | // --------------------------------------------------------------------------- |
| 130 |
nothing calls this directly
no test coverage detected