{ // Assert it round-trips through copy-ctor.
nsHttpResponseHead copied(aHead);
ASSERT_EQ(aHead, copied);
}
{ // Assert it round-trips through operator=
nsHttpResponseHead copied;
copied = aHead; // It is important that the below statement cannot be // ASSERT_EQ(aHead, copied) to avoid potential lock-order inversion problem. // See Bug 1829445 for more details
ASSERT_EQ(copied, aHead);
}
}
TEST(TestHttpResponseHead, atoms)
{ // Test that the resolving the content-type atom returns the initial static
ASSERT_EQ(nsHttp::Content_Type, nsHttp::ResolveAtom("content-type"_ns)); // Check that they're case insensitive
ASSERT_EQ(nsHttp::ResolveAtom("Content-Type"_ns),
nsHttp::ResolveAtom("content-type"_ns)); // This string literal should be the backing of the atom when resolved first auto header1 = "CustomHeaderXXX1"_ns; auto atom1 = nsHttp::ResolveAtom(header1); auto header2 = "customheaderxxx1"_ns; auto atom2 = nsHttp::ResolveAtom(header2);
ASSERT_EQ(atom1, atom2);
ASSERT_EQ(atom1.get(), atom2.get()); // Check that we get the expected pointer back.
ASSERT_EQ(atom2.get(), header1.BeginReading());
}
// Move construct a new object from the initial one
nsHttpResponseHead movedHead(std::move(originalHead));
// Ensure the moved head retains the original status
ASSERT_EQ(movedHead.Status(), 200);
nsCString value;
ASSERT_EQ(movedHead.GetHeader(nsHttp::Content_Type, value), NS_OK);
ASSERT_EQ(value, "text/plain"_ns);
ASSERT_EQ(movedHead.GetHeader(nsHttp::Content_Length, value), NS_OK);
ASSERT_EQ(value, "1408"_ns);
// Check original object is in an unspecified state
ASSERT_EQ(originalHead.GetHeader(nsHttp::Content_Type, value),
NS_ERROR_NOT_AVAILABLE);
ASSERT_FALSE(originalHead.HasHeader(nsHttp::Content_Type));
ASSERT_FALSE(originalHead.HasHeader(nsHttp::Content_Length));
}
} // namespace net
} // namespace mozilla
Messung V0.5
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.