~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/tests/testHttpRequestMethod.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#define SQUID_UNIT_TEST 1 
 
1
#define SQUID_UNIT_TEST 1
2
2
 
3
3
#include "squid.h"
4
 
#include <sstream>
5
4
#include <cppunit/TestAssert.h>
6
5
 
7
6
#include "Mem.h"
8
7
#include "testHttpRequestMethod.h"
9
8
#include "HttpRequestMethod.h"
10
9
 
 
10
#if HAVE_SSTREAM
 
11
#include <sstream>
 
12
#endif
11
13
 
12
14
CPPUNIT_TEST_SUITE_REGISTRATION( testHttpRequestMethod );
13
15
 
19
21
testHttpRequestMethod::testConstructCharStart()
20
22
{
21
23
    /* parse an empty string -> METHOD_NONE */
22
 
    CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL));
 
24
    CPPUNIT_ASSERT(HttpRequestMethod(NULL,NULL) == METHOD_NONE);
23
25
    /* parsing a literal should work */
24
 
    CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
 
26
    CPPUNIT_ASSERT(HttpRequestMethod("GET", NULL) == METHOD_GET);
 
27
    CPPUNIT_ASSERT(HttpRequestMethod("QWERTY", NULL) == METHOD_OTHER);
25
28
}
26
29
 
27
30
/*
28
 
 * We can also parse precise ranges of characters 
 
31
 * We can also parse precise ranges of characters
29
32
 */
30
33
void
31
34
testHttpRequestMethod::testConstructCharStartEnd()
32
35
{
33
36
    char const * buffer;
34
37
    /* parse an empty string -> METHOD_NONE */
35
 
    CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL, NULL));
 
38
    CPPUNIT_ASSERT(HttpRequestMethod(NULL, NULL) == METHOD_NONE);
36
39
    /* parsing a literal should work */
37
 
    CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
 
40
    CPPUNIT_ASSERT(HttpRequestMethod("GET", NULL) == METHOD_GET);
38
41
    /* parsing with an explicit end should work */
39
42
    buffer = "POSTPLUS";
40
 
    CPPUNIT_ASSERT(METHOD_POST == HttpRequestMethod(buffer, buffer + 4));
 
43
    CPPUNIT_ASSERT(HttpRequestMethod(buffer, buffer + 4) == METHOD_POST);
41
44
}
42
45
 
43
46
/*
79
82
 * we should be able to get a char const * version of the method.
80
83
 */
81
84
void
82
 
testHttpRequestMethod::testConst_str()
 
85
testHttpRequestMethod::testImage()
83
86
{
84
 
    CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post").const_str()));
 
87
    CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post",NULL).image()));
85
88
}
86
89
 
87
90
/*
93
96
{
94
97
    CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) == METHOD_NONE);
95
98
    CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_POST) == METHOD_GET));
96
 
    CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod(METHOD_GET));
97
 
    CPPUNIT_ASSERT(not (METHOD_SEARCH == HttpRequestMethod(METHOD_TRACE)));
 
99
    CPPUNIT_ASSERT(HttpRequestMethod(METHOD_GET) == METHOD_GET);
 
100
    CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_TRACE) == METHOD_SEARCH));
98
101
}
99
102
 
100
103
/*
105
108
{
106
109
    CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) != METHOD_GET);
107
110
    CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_POST) != METHOD_POST));
108
 
    CPPUNIT_ASSERT(METHOD_NONE != HttpRequestMethod(METHOD_GET));
109
 
    CPPUNIT_ASSERT(not (METHOD_SEARCH != HttpRequestMethod(METHOD_SEARCH)));
 
111
    CPPUNIT_ASSERT(HttpRequestMethod(METHOD_GET) != METHOD_NONE);
 
112
    CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_SEARCH) != METHOD_SEARCH));
110
113
}
111
114
 
112
115
/*
116
119
testHttpRequestMethod::testStream()
117
120
{
118
121
    std::ostringstream buffer;
119
 
    buffer << HttpRequestMethod("get");
 
122
    buffer << HttpRequestMethod("get",NULL);
120
123
    CPPUNIT_ASSERT_EQUAL(String("GET"), String(buffer.str().c_str()));
121
124
}