test/TestUtil: move to test/util/
This commit is contained in:
34
test/util/TestUriQueryParser.cxx
Normal file
34
test/util/TestUriQueryParser.cxx
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Unit tests for src/util/
|
||||
*/
|
||||
|
||||
#include "util/UriQueryParser.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
static bool
|
||||
operator==(StringView a, StringView b)
|
||||
{
|
||||
if (a.IsNull() || b.IsNull())
|
||||
return a.IsNull() == b.IsNull();
|
||||
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
TEST(UriQueryParser, UriFindRawQueryParameter)
|
||||
{
|
||||
const char *q = "foo=1&bar=2"ed=%20%00+%%&empty1&empty2=";
|
||||
EXPECT_EQ(UriFindRawQueryParameter(q, "doesntexist"),
|
||||
(const char *)nullptr);
|
||||
EXPECT_EQ(UriFindRawQueryParameter(q, "foo"),
|
||||
"1");
|
||||
EXPECT_EQ(UriFindRawQueryParameter(q, "bar"),
|
||||
"2");
|
||||
EXPECT_EQ(UriFindRawQueryParameter(q, "quoted"),
|
||||
"%20%00+%%");
|
||||
EXPECT_EQ(UriFindRawQueryParameter(q, "empty1"),
|
||||
"");
|
||||
EXPECT_EQ(UriFindRawQueryParameter(q, "empty2"),
|
||||
"");
|
||||
}
|
Reference in New Issue
Block a user