MCPcopy Create free account
hub / github.com/OSGeo/PROJ / TEST

Function TEST

test/unit/proj_context_test.cpp:91–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89// ---------------------------------------------------------------------------
90
91TEST(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

Callers

nothing calls this directly

Calls 12

createTempDictFunction · 0.85
proj_context_createFunction · 0.85
proj_createFunction · 0.85
proj_destroyFunction · 0.85
proj_context_destroyFunction · 0.85
MyUnlinkFunction · 0.85
createTmpFileFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected