This is an automated email from the ASF dual-hosted git repository.

tschoening pushed a commit to branch ghpr_13
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit 82024ff5650bca32428f5f1385707d77d877ebf4
Author: Thorsten Schöning <[email protected]>
AuthorDate: Tue Oct 22 21:59:14 2019 +0200

    Removed debugging output, replaced "\n" with LOG4CXX_EOL to get in line 
with the other code and added 0x00 to the raw arrays of logchars or appending 
strings didn't work.
---
 src/test/cpp/jsonlayouttest.cpp | 103 ++++++++++++++++++++++------------------
 1 file changed, 56 insertions(+), 47 deletions(-)

diff --git a/src/test/cpp/jsonlayouttest.cpp b/src/test/cpp/jsonlayouttest.cpp
index 2cc7419..a23aa2e 100644
--- a/src/test/cpp/jsonlayouttest.cpp
+++ b/src/test/cpp/jsonlayouttest.cpp
@@ -125,35 +125,38 @@ public:
         */
        void testAppendQuotedEscapedStringWithControlChars()
        {
-        // TODO fails
-               return;
-               logchar bs[] = {0x08};
-               logchar bs_expected[] = {0x22, 0x5c, 'b', 0x22};      /* "\b" */
+               logchar bs[] = {0x08, 0x00};
+               logchar bs_expected[] = {0x22, 0x5c, 'b', 0x22, 0x00};      /* 
"\b" */
                LogString bs_escaped;
+
                appendQuotedEscapedString(bs_escaped, bs);
                LOGUNIT_ASSERT_EQUAL(bs_expected, bs_escaped);
 
-               logchar tab[] = {0x09};
-               logchar tab_expected[] = {0x22, 0x5c, 't', 0x22};     /* "\t" */
+               logchar tab[] = {0x09, 0x00};
+               logchar tab_expected[] = {0x22, 0x5c, 't', 0x22, 0x00};     /* 
"\t" */
                LogString tab_escaped;
+
                appendQuotedEscapedString(tab_escaped, tab);
                LOGUNIT_ASSERT_EQUAL(tab_expected, tab_escaped);
 
-               logchar newline[] = {0x0a};
-               logchar newline_expected[] = {0x22, 0x5c, 'n', 0x22}; /* "\n" */
+               logchar newline[] = {0x0a, 0x00};
+               logchar newline_expected[] = {0x22, 0x5c, 'n', 0x22, 0x00}; /* 
"\n" */
                LogString newline_escaped;
+
                appendQuotedEscapedString(newline_escaped, newline);
                LOGUNIT_ASSERT_EQUAL(newline_expected, newline_escaped);
 
-               logchar ff[] = {0x0c};
-               logchar ff_expected[] = {0x22, 0x5c, 'f', 0x22};      /* "\f" */
+               logchar ff[] = {0x0c, 0x00};
+               logchar ff_expected[] = {0x22, 0x5c, 'f', 0x22, 0x00};      /* 
"\f" */
                LogString ff_escaped;
+
                appendQuotedEscapedString(ff_escaped, ff);
                LOGUNIT_ASSERT_EQUAL(ff_expected, ff_escaped);
 
-               logchar cr[] = {0x0d};
-               logchar cr_expected[] = {0x22, 0x5c, 'r', 0x22};      /* "\r" */
+               logchar cr[] = {0x0d, 0x00};
+               logchar cr_expected[] = {0x22, 0x5c, 'r', 0x22, 0x00};      /* 
"\r" */
                LogString cr_escaped;
+
                appendQuotedEscapedString(cr_escaped, cr);
                LOGUNIT_ASSERT_EQUAL(cr_expected, cr_escaped);
        }
@@ -196,13 +199,17 @@ public:
                LogString expected1;
 
                expected1
-               .append(LOG4CXX_STR(",\n"))
+               .append(LOG4CXX_STR(","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
-               .append(LOG4CXX_STR("\"context_map\": {\n"))
+               .append(LOG4CXX_STR("\"context_map\": {"))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL2)
-               .append(LOG4CXX_STR("\"key1\": \"value1\",\n"))
+               .append(LOG4CXX_STR("\"key1\": \"value1\","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL2)
-               .append(LOG4CXX_STR("\"key2\": \"value2\"\n"))
+               .append(LOG4CXX_STR("\"key2\": \"value2\""))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
                .append(LOG4CXX_STR("}"));
 
@@ -251,11 +258,14 @@ public:
                LogString expected1;
 
                expected1
-               .append(LOG4CXX_STR(",\n"))
+               .append(LOG4CXX_STR(","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
-               .append(LOG4CXX_STR("\"context_stack\": [\n"))
+               .append(LOG4CXX_STR("\"context_stack\": ["))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL2)
-               .append(LOG4CXX_STR("\"one two three\"\n"))
+               .append(LOG4CXX_STR("\"one two three\""))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
                .append(LOG4CXX_STR("]"));
 
@@ -308,15 +318,20 @@ public:
 
                expected1
                .append(ppIndentL1)
-               .append(LOG4CXX_STR("\"location_info\": {\n"))
+               .append(LOG4CXX_STR("\"location_info\": {"))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL2)
-               .append(LOG4CXX_STR("\"file\": \"FooFile\",\n"))
+               .append(LOG4CXX_STR("\"file\": \"FooFile\","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL2)
-               .append(LOG4CXX_STR("\"line\": \"42\",\n"))
+               .append(LOG4CXX_STR("\"line\": \"42\","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL2)
-               .append(LOG4CXX_STR("\"class\": \"\",\n"))
+               .append(LOG4CXX_STR("\"class\": \"\","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL2)
-               .append(LOG4CXX_STR("\"method\": \"BarFunc\"\n"))
+               .append(LOG4CXX_STR("\"method\": \"BarFunc\""))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
                .append(LOG4CXX_STR("}"));
 
@@ -331,7 +346,6 @@ public:
         */
        void testFormat()
        {
-        // TODO fails
                Pool p;
 
                LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
@@ -368,13 +382,10 @@ public:
                expected1.append(LOG4CXX_STR(", "));
                appendSerializedLocationInfo(expected1, event1, p);
 
-               expected1.append(LOG4CXX_STR(" }\n"));
+               expected1.append(LOG4CXX_STR(" }"));
+               expected1.append(LOG4CXX_EOL);
                format(output1, event1, p);
-std::wcout << L"\n";
-std::wcout << L"---" << expected1.c_str() << L"---\n";
-std::wcout << L"---" << output1.c_str() << L"---\n";
-std::cout << expected1.length() << "\n";
-std::cout << output1.length() << "\n";
+
                LOGUNIT_ASSERT_EQUAL(expected1, output1);
        }
 
@@ -383,8 +394,6 @@ std::cout << output1.length() << "\n";
         */
        void testFormatWithPrettyPrint()
        {
-               // TODO fails
-               return;
                Pool p;
 
                LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
@@ -407,15 +416,19 @@ std::cout << output1.length() << "\n";
                LogString expected1;
 
                expected1
-               .append(LOG4CXX_STR("{\n"))
+               .append(LOG4CXX_STR("{"))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
                .append(LOG4CXX_STR("\"timestamp\": \""))
                .append(timestamp)
-               .append(LOG4CXX_STR("\",\n"))
+               .append(LOG4CXX_STR("\","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
-               .append(LOG4CXX_STR("\"level\": \"INFO\",\n"))
+               .append(LOG4CXX_STR("\"level\": \"INFO\","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
-               .append(LOG4CXX_STR("\"logger\": \"Logger\",\n"))
+               .append(LOG4CXX_STR("\"logger\": \"Logger\","))
+               .append(LOG4CXX_EOL)
                .append(ppIndentL1)
                .append(LOG4CXX_STR("\"message\": \"A message goes here.\""));
 
@@ -424,19 +437,15 @@ std::cout << output1.length() << "\n";
 
                appendSerializedMDC(expected1, event1);
                appendSerializedNDC(expected1, event1);
-               expected1.append(LOG4CXX_STR(",\n"));
+               expected1.append(LOG4CXX_STR(","));
+               expected1.append(LOG4CXX_EOL);
                appendSerializedLocationInfo(expected1, event1, p);
 
-               expected1.append(LOG4CXX_STR("\n}\n"));
+               expected1.append(LOG4CXX_EOL);
+               expected1.append(LOG4CXX_STR("}"));
+               expected1.append(LOG4CXX_EOL);
                format(output1, event1, p);
-#include <log4cxx/helpers/stringhelper.h>
-std::wcout << L"\n";
-std::wcout << L"---" << expected1.c_str() << L"---\n";
-std::wcout << L"---" << output1.c_str() << L"---\n";
-std::cout << expected1.length() << "\n";
-std::cout << output1.length() << "\n";
-std::cout << expected1.length() << "\n";
-std::cout << StringHelper::trim(output1).length() << "\n";
+
                LOGUNIT_ASSERT_EQUAL(expected1, output1);
        }
 

Reply via email to