UriParser cleanup

- move the header file to the include folder
- enclose the class in the proper namespace

llvm-svn: 294741
This commit is contained in:
Pavel Labath
2017-02-10 12:21:22 +00:00
parent 463cb8ac30
commit 5f7e583b33
9 changed files with 28 additions and 48 deletions

View File

@@ -10,14 +10,9 @@
#ifndef utility_UriParser_h_
#define utility_UriParser_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
// Project includes
namespace lldb_private {
class UriParser {
public:
// Parses
@@ -32,5 +27,6 @@ public:
llvm::StringRef &hostname, int &port,
llvm::StringRef &path);
};
}
#endif // utility_UriParser_h_

View File

@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "Utility/UriParser.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -19,6 +15,7 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Utility/UriParser.h"
// Project includes
#include "AdbClient.h"

View File

@@ -12,9 +12,9 @@
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Utility/Error.h"
#include "lldb/Utility/UriParser.h"
#include "PlatformAndroidRemoteGDBServer.h"
#include "Utility/UriParser.h"
#include <sstream>

View File

@@ -30,8 +30,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/Error.h"
#include "lldb/Utility/StreamString.h"
#include "Utility/UriParser.h"
#include "lldb/Utility/UriParser.h"
#include "Plugins/Process/Utility/GDBRemoteSignals.h"

View File

@@ -42,6 +42,7 @@
#include "lldb/Utility/JSON.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/UriParser.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/ScopedPrinter.h"
@@ -49,7 +50,6 @@
#include "ProcessGDBRemote.h"
#include "ProcessGDBRemoteLog.h"
#include "Utility/StringExtractorGDBRemote.h"
#include "Utility/UriParser.h"
using namespace lldb;
using namespace lldb_private;

View File

@@ -36,10 +36,10 @@
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/JSON.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/UriParser.h"
// Project includes
#include "Utility/StringExtractorGDBRemote.h"
#include "Utility/UriParser.h"
using namespace lldb;
using namespace lldb_private;

View File

@@ -7,16 +7,7 @@
//
//===----------------------------------------------------------------------===//
#include "Utility/UriParser.h"
// C Includes
// C++ Includes
#include <cstring>
// Other libraries and framework includes
// Project includes
#include "lldb/Host/StringConvert.h"
#include "lldb/Utility/UriParser.h"
using namespace lldb_private;

View File

@@ -15,8 +15,7 @@
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Utility/StreamString.h"
#include "Utility/UriParser.h"
#include "lldb/Utility/UriParser.h"
using namespace lldb;
using namespace lldb_private;

View File

@@ -1,9 +1,7 @@
#include "Utility/UriParser.h"
#include "lldb/Utility/UriParser.h"
#include "gtest/gtest.h"
namespace {
class UriParserTest : public ::testing::Test {};
}
using namespace lldb_private;
// result strings (scheme/hostname/port/path) passed into UriParser::Parse
// are initialized to kAsdf so we can verify that they are unmodified if the
@@ -41,12 +39,12 @@ public:
EXPECT_EQ(testCase.m_port, port); \
EXPECT_STREQ(testCase.m_path, path.str().c_str());
TEST_F(UriParserTest, Minimal) {
TEST(UriParserTest, Minimal) {
const UriTestCase testCase("x://y", "x", "y", -1, "/");
VALIDATE
}
TEST_F(UriParserTest, MinimalPort) {
TEST(UriParserTest, MinimalPort) {
const UriTestCase testCase("x://y:1", "x", "y", 1, "/");
llvm::StringRef scheme(kAsdf);
llvm::StringRef hostname(kAsdf);
@@ -61,28 +59,28 @@ TEST_F(UriParserTest, MinimalPort) {
EXPECT_STREQ(testCase.m_path, path.str().c_str());
}
TEST_F(UriParserTest, MinimalPath) {
TEST(UriParserTest, MinimalPath) {
const UriTestCase testCase("x://y/", "x", "y", -1, "/");
VALIDATE
}
TEST_F(UriParserTest, MinimalPortPath) {
TEST(UriParserTest, MinimalPortPath) {
const UriTestCase testCase("x://y:1/", "x", "y", 1, "/");
VALIDATE
}
TEST_F(UriParserTest, LongPath) {
TEST(UriParserTest, LongPath) {
const UriTestCase testCase("x://y/abc/def/xyz", "x", "y", -1, "/abc/def/xyz");
VALIDATE
}
TEST_F(UriParserTest, TypicalPortPath) {
TEST(UriParserTest, TypicalPortPath) {
const UriTestCase testCase("connect://192.168.100.132:5432/", "connect",
"192.168.100.132", 5432, "/");
VALIDATE;
}
TEST_F(UriParserTest, BracketedHostnamePort) {
TEST(UriParserTest, BracketedHostnamePort) {
const UriTestCase testCase("connect://[192.168.100.132]:5432/", "connect",
"192.168.100.132", 5432, "/");
llvm::StringRef scheme(kAsdf);
@@ -98,54 +96,54 @@ TEST_F(UriParserTest, BracketedHostnamePort) {
EXPECT_STREQ(testCase.m_path, path.str().c_str());
}
TEST_F(UriParserTest, BracketedHostname) {
TEST(UriParserTest, BracketedHostname) {
const UriTestCase testCase("connect://[192.168.100.132]", "connect",
"192.168.100.132", -1, "/");
VALIDATE
}
TEST_F(UriParserTest, BracketedHostnameWithColon) {
TEST(UriParserTest, BracketedHostnameWithColon) {
const UriTestCase testCase("connect://[192.168.100.132:5555]:1234", "connect",
"192.168.100.132:5555", 1234, "/");
VALIDATE
}
TEST_F(UriParserTest, SchemeHostSeparator) {
TEST(UriParserTest, SchemeHostSeparator) {
const UriTestCase testCase("x:/y");
VALIDATE
}
TEST_F(UriParserTest, SchemeHostSeparator2) {
TEST(UriParserTest, SchemeHostSeparator2) {
const UriTestCase testCase("x:y");
VALIDATE
}
TEST_F(UriParserTest, SchemeHostSeparator3) {
TEST(UriParserTest, SchemeHostSeparator3) {
const UriTestCase testCase("x//y");
VALIDATE
}
TEST_F(UriParserTest, SchemeHostSeparator4) {
TEST(UriParserTest, SchemeHostSeparator4) {
const UriTestCase testCase("x/y");
VALIDATE
}
TEST_F(UriParserTest, BadPort) {
TEST(UriParserTest, BadPort) {
const UriTestCase testCase("x://y:a/");
VALIDATE
}
TEST_F(UriParserTest, BadPort2) {
TEST(UriParserTest, BadPort2) {
const UriTestCase testCase("x://y:5432a/");
VALIDATE
}
TEST_F(UriParserTest, Empty) {
TEST(UriParserTest, Empty) {
const UriTestCase testCase("");
VALIDATE
}
TEST_F(UriParserTest, PortOverflow) {
TEST(UriParserTest, PortOverflow) {
const UriTestCase testCase("x://"
"y:"
"0123456789012345678901234567890123456789012345678"