MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / test_case

Function test_case

net/http/test/server_function_test.cpp:125–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123std::string fs_handler_std_str = "01234567890123456789";
124
125void test_case(Client* client, estring_view url, off_t st, size_t len, size_t exp_content_length, bool invalid = false) {
126 LOG_INFO("test case start");
127 auto op = client->new_operation(Verb::GET, url);
128 DEFER(client->destroy_operation(op));
129 op->req.headers.range(st, st + len - 1);
130 auto ret = op->call();
131 LOG_INFO("call finished");
132 EXPECT_EQ(0, ret);
133 if (invalid) return;
134
135 if (exp_content_length != fs_handler_std_str.size()) {
136 EXPECT_EQ(206, op->resp.status_code());
137 } else {
138 EXPECT_EQ(200, op->resp.status_code());
139 }
140 char buf[4096];
141 ret = op->resp.read(buf, 4096);
142 EXPECT_EQ(exp_content_length, ret);
143 if ((size_t)st >= fs_handler_std_str.size()) len = 0;
144 else if ((size_t)st + len > fs_handler_std_str.size())
145 len = fs_handler_std_str.size() - st;
146 std::string_view x(fs_handler_std_str.data() + st, len);
147 std::string_view y(buf, exp_content_length);
148 EXPECT_EQ(x, y);
149}
150
151void test_head_case(Client* client, estring_view url, off_t st, size_t len, size_t exp_content_length) {
152 LOG_INFO("test HEAD case start");

Callers 1

TESTFunction · 0.70

Calls 8

new_operationMethod · 0.45
destroy_operationMethod · 0.45
rangeMethod · 0.45
callMethod · 0.45
sizeMethod · 0.45
status_codeMethod · 0.45
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected