Add a variadic overload of Log::arg() to print all arguments
Additionally limit the scope of the arg(bool) overload to fix literal
strings being logged as 'true'. Found while adding a few more tests...
Test: atest netdutils_test
Change-Id: If2c398bab6c2c809274e6b2d247cdb38494cb8e3
diff --git a/libnetdutils/LogTest.cpp b/libnetdutils/LogTest.cpp
index 20f3e1e..e95b30d 100644
--- a/libnetdutils/LogTest.cpp
+++ b/libnetdutils/LogTest.cpp
@@ -110,5 +110,28 @@
EXPECT_EQ("BBB::prettyFunctionName()", entry.toString());
}
+TEST(LogEntryTest, PrintChainedArguments) {
+ const LogEntry entry = LogEntry()
+ .function("testFunc")
+ .arg("hello")
+ .arg(42)
+ .arg(true);
+ EXPECT_EQ("testFunc(hello, 42, true)", entry.toString());
+}
+
+TEST(LogEntryTest, PrintIntegralTypes) {
+ const LogEntry entry = LogEntry()
+ .function("testFunc")
+ .arg('A')
+ .arg(100U)
+ .arg(-1000LL);
+ EXPECT_EQ("testFunc(65, 100, -1000)", entry.toString());
+}
+
+TEST(LogEntryTest, PrintArgumentPack) {
+ const LogEntry entry = LogEntry().function("testFunc").args("hello", 42, false);
+ EXPECT_EQ("testFunc(hello, 42, false)", entry.toString());
+}
+
} // namespace netdutils
} // namespace android