phosphor-rsyslog-conf: add unit tests

Add tests pertaining to remote logging config file.

Change-Id: Idaeac09b5abe91af30dc0eb32664e8af556ecda2
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/test/remote_logging_test_config.cpp b/test/remote_logging_test_config.cpp
new file mode 100644
index 0000000..8c3a98a
--- /dev/null
+++ b/test/remote_logging_test_config.cpp
@@ -0,0 +1,58 @@
+#include "remote_logging_tests.hpp"
+#include <fstream>
+
+namespace phosphor
+{
+namespace logging
+{
+namespace test
+{
+
+std::string getConfig(const char* filePath)
+{
+    std::fstream stream(filePath, std::fstream::in);
+    std::string line;
+    getline(stream, line);
+    return line;
+}
+
+TEST_F(TestRemoteLogging, testOnlyAddress)
+{
+    config->address("1.1.1.1");
+    EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
+}
+
+TEST_F(TestRemoteLogging, testOnlyPort)
+{
+    config->port(100);
+    EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
+}
+
+TEST_F(TestRemoteLogging, testGoodConfig)
+{
+    config->address("1.1.1.1");
+    config->port(100);
+    EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
+}
+
+TEST_F(TestRemoteLogging, testClearAddress)
+{
+    config->address("1.1.1.1");
+    config->port(100);
+    EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
+    config->address("");
+    EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
+}
+
+TEST_F(TestRemoteLogging, testClearPort)
+{
+    config->address("1.1.1.1");
+    config->port(100);
+    EXPECT_EQ(getConfig(configFilePath.c_str()), "*.* @@1.1.1.1:100");
+    config->port(0);
+    EXPECT_EQ(getConfig(configFilePath.c_str()), "#*.* @@remote-host:port");
+}
+
+}// namespace test
+}// namespace logging
+}// namespace phosphor