+#define SQUID_UNIT_TEST 1
+
#include "squid.h"
-#include <sstream>
#include <cppunit/TestAssert.h>
#include "Mem.h"
#include "testHttpRequestMethod.h"
#include "HttpRequestMethod.h"
+#if HAVE_SSTREAM
+#include <sstream>
+#endif
CPPUNIT_TEST_SUITE_REGISTRATION( testHttpRequestMethod );
-
/*
* We should be able to make an HttpRequestMethod straight from a string.
*/
testHttpRequestMethod::testConstructCharStart()
{
/* parse an empty string -> METHOD_NONE */
- CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL));
+ CPPUNIT_ASSERT(HttpRequestMethod(NULL,NULL) == METHOD_NONE);
/* parsing a literal should work */
- CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
+ CPPUNIT_ASSERT(HttpRequestMethod("GET", NULL) == METHOD_GET);
+ CPPUNIT_ASSERT(HttpRequestMethod("QWERTY", NULL) == METHOD_OTHER);
}
/*
- * We can also parse precise ranges of characters
+ * We can also parse precise ranges of characters
*/
void
testHttpRequestMethod::testConstructCharStartEnd()
{
char const * buffer;
/* parse an empty string -> METHOD_NONE */
- CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL, NULL));
+ CPPUNIT_ASSERT(HttpRequestMethod(NULL, NULL) == METHOD_NONE);
/* parsing a literal should work */
- CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
+ CPPUNIT_ASSERT(HttpRequestMethod("GET", NULL) == METHOD_GET);
/* parsing with an explicit end should work */
buffer = "POSTPLUS";
- CPPUNIT_ASSERT(METHOD_POST == HttpRequestMethod(buffer, buffer + 4));
+ CPPUNIT_ASSERT(HttpRequestMethod(buffer, buffer + 4) == METHOD_POST);
}
/*
* we should be able to get a char const * version of the method.
*/
void
-testHttpRequestMethod::testConst_str()
+testHttpRequestMethod::testImage()
{
- CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post").const_str()));
+ CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post",NULL).image()));
}
/*
{
CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) == METHOD_NONE);
CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_POST) == METHOD_GET));
- CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod(METHOD_GET));
- CPPUNIT_ASSERT(not (METHOD_SEARCH == HttpRequestMethod(METHOD_TRACE)));
+ CPPUNIT_ASSERT(HttpRequestMethod(METHOD_GET) == METHOD_GET);
+ CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_TRACE) == METHOD_SEARCH));
}
/*
{
CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) != METHOD_GET);
CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_POST) != METHOD_POST));
- CPPUNIT_ASSERT(METHOD_NONE != HttpRequestMethod(METHOD_GET));
- CPPUNIT_ASSERT(not (METHOD_SEARCH != HttpRequestMethod(METHOD_SEARCH)));
+ CPPUNIT_ASSERT(HttpRequestMethod(METHOD_GET) != METHOD_NONE);
+ CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_SEARCH) != METHOD_SEARCH));
}
/*
testHttpRequestMethod::testStream()
{
std::ostringstream buffer;
- buffer << HttpRequestMethod("get");
+ buffer << HttpRequestMethod("get",NULL);
CPPUNIT_ASSERT_EQUAL(String("GET"), String(buffer.str().c_str()));
}