MCPcopy Create free account
hub / github.com/apache/mesos / TEST

Function TEST

3rdparty/libprocess/src/tests/encoder_tests.cpp:39–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38
39TEST(EncoderTest, Response)
40{
41 http::Request request;
42 const http::OK response("body");
43
44 // Encode the response.
45 const string encoded = HttpResponseEncoder::encode(response, request);
46
47 // Now decode it back, and verify the encoding was correct.
48 ResponseDecoder decoder;
49 deque<http::Response*> responses =
50 decoder.decode(encoded.data(), encoded.length());
51
52 ASSERT_FALSE(decoder.failed());
53 ASSERT_EQ(1u, responses.size());
54
55 Owned<http::Response> decoded(responses[0]);
56 EXPECT_EQ("200 OK", decoded->status);
57 EXPECT_EQ("body", decoded->body);
58
59 // Encoding should have inserted the 'Date', 'Content-Length' and
60 // 'Content-Type' headers.
61 EXPECT_EQ(3u, decoded->headers.size());
62 EXPECT_TRUE(decoded->headers.contains("Date"));
63 EXPECT_SOME_EQ(
64 stringify(response.body.size()),
65 decoded->headers.get("Content-Length"));
66 EXPECT_SOME_EQ(
67 "text/plain; charset=utf-8",
68 decoded->headers.get("Content-Type"));
69}
70
71
72TEST(EncoderTest, AcceptableEncodings)

Callers

nothing calls this directly

Calls 8

dataMethod · 0.80
encodeFunction · 0.50
stringifyClass · 0.50
decodeMethod · 0.45
failedMethod · 0.45
sizeMethod · 0.45
containsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected