#![allow(non_snake_case)]
use goish::prelude::*;
test!{ fn TestStatusTextKnown(t) {
let cases = vec![
(200, "OK"),
(201, "Created"),
(204, "No Content"),
(301, "Moved Permanently"),
(302, "Found"),
(304, "Not Modified"),
(400, "Bad Request"),
(401, "Unauthorized"),
(404, "Not Found"),
(418, "I'm a teapot"),
(500, "Internal Server Error"),
(503, "Service Unavailable"),
];
for (code, want) in cases {
let got = http::StatusText(code);
if got != want {
t.Errorf(Sprintf!("StatusText(%d) = %q, want %q", code, got, want));
}
}
}}
test!{ fn TestStatusTextUnknown(t) {
let got = http::StatusText(999);
if got != "" {
t.Errorf(Sprintf!("StatusText(999) = %q, want empty", got));
}
}}
test!{ fn TestStatusConstants(t) {
if http::StatusOK != 200 { t.Errorf(Sprintf!("StatusOK = %d", http::StatusOK)); }
if http::StatusNotFound != 404 { t.Errorf(Sprintf!("StatusNotFound = %d", http::StatusNotFound)); }
if http::StatusInternalServerError != 500 {
t.Errorf(Sprintf!("StatusInternalServerError = %d", http::StatusInternalServerError));
}
}}
test!{ fn TestHeaderOnResponse(t) {
let mut h = http::Header::new();
h.Set("Content-Type", "application/json");
h.Add("X-Multi", "v1");
h.Add("X-Multi", "v2");
if h.Get("content-type") != "application/json" {
t.Errorf(Sprintf!("Case-insensitive Get failed"));
}
let values = h.Values("x-multi");
if values.len() != 2 {
t.Errorf(Sprintf!("Values len = %d", values.len()));
}
}}