File: http_response_tests.cpp

package info (click to toggle)
pion 5.0.7%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,048 kB
  • ctags: 3,122
  • sloc: cpp: 14,237; perl: 269; pascal: 152; makefile: 145; sh: 70
file content (56 lines) | stat: -rw-r--r-- 1,990 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// ---------------------------------------------------------------------
// pion:  a Boost C++ framework for building lightweight HTTP interfaces
// ---------------------------------------------------------------------
// Copyright (C) 2007-2014 Splunk Inc.  (https://github.com/splunk/pion)
//
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//

#include <pion/config.hpp>
#include <pion/http/response.hpp>
#include <boost/test/unit_test.hpp>

using namespace pion;

class NewHTTPResponse_F : public http::response {
public:
    NewHTTPResponse_F() {
    }
    ~NewHTTPResponse_F() {
    }
};

BOOST_FIXTURE_TEST_SUITE(NewHTTPResponse_S, NewHTTPResponse_F)

BOOST_AUTO_TEST_CASE(checkClear) {
    prepare_headers_for_send(true, false);
    BOOST_CHECK(!get_headers().empty());
    clear();
    BOOST_CHECK(get_headers().empty());
}

BOOST_AUTO_TEST_CASE(checkStatusCodeAccessors) {
    set_status_code(http::types::RESPONSE_CODE_NOT_FOUND);
    BOOST_CHECK_EQUAL(get_status_code(), http::types::RESPONSE_CODE_NOT_FOUND);
    set_status_code(http::types::RESPONSE_CODE_CREATED);
    BOOST_CHECK_EQUAL(get_status_code(), http::types::RESPONSE_CODE_CREATED);
}

BOOST_AUTO_TEST_CASE(checkStatusMessageAccessors) {
    set_status_message(http::types::RESPONSE_MESSAGE_NOT_FOUND);
    BOOST_CHECK_EQUAL(get_status_message(), http::types::RESPONSE_MESSAGE_NOT_FOUND);
    set_status_message(http::types::RESPONSE_MESSAGE_CREATED);
    BOOST_CHECK_EQUAL(get_status_message(), http::types::RESPONSE_MESSAGE_CREATED);
}

BOOST_AUTO_TEST_CASE(checkSetLastModified) {
    set_last_modified(0);
    BOOST_CHECK_EQUAL(get_header(HEADER_LAST_MODIFIED), get_date_string(0));
    set_last_modified(100000000);
    BOOST_CHECK_EQUAL(get_header(HEADER_LAST_MODIFIED), get_date_string(100000000));
    set_last_modified(1000000000);
    BOOST_CHECK_EQUAL(get_header(HEADER_LAST_MODIFIED), get_date_string(1000000000));
}

BOOST_AUTO_TEST_SUITE_END()