swebb2066 commented on code in PR #722:
URL: https://github.com/apache/logging-log4cxx/pull/722#discussion_r3610038500


##########
src/test/cpp/mdctestcase.cpp:
##########
@@ -74,6 +75,16 @@ LOGUNIT_CLASS(MDCTestCase)
                l.format(output, 
std::make_shared<spi::LoggingEvent>(LOG4CXX_STR("MDC.LayoutTest"), 
Level::getInfo(), LOG4CXX_STR("Message"), 
spi::LocationInfo::getLocationUnavailable()));
                LOGUNIT_ASSERT_EQUAL(LOG4CXX_STR("INFO  MDC.LayoutTest - 
{\"key1\":\"value1\"} Message"), output);
        }
+
+       /// A maximum field length of zero must suppress all MDC content 
instead of underflowing.
+       void test3()
+       {
+               MDC item1("key1", "value1");
+               LogString output;
+               PatternLayout l{ LOG4CXX_STR("%-5p %c - %.0J %m") };
+               l.format(output, 
std::make_shared<spi::LoggingEvent>(LOG4CXX_STR("MDC.LayoutTest"), 
Level::getInfo(), LOG4CXX_STR("Message"), 
spi::LocationInfo::getLocationUnavailable()));

Review Comment:
   This test passes even without the mdcptternconverter.cpp change. To create a 
failing test, use the following:
   ```
                pattern::MDCPatternConverter converter;
                bool leftAlign{false};
                const int minLength{0}, maxLength{0};
                
converter.setFormattingInfo(std::make_shared<pattern::FormattingInfo>(leftAlign,
 minLength, maxLength));
                MDC item1("key1", "value1");
                auto e = 
std::make_shared<spi::LoggingEvent>(LOG4CXX_STR("MDC.LayoutTest"), 
Level::getInfo(), LOG4CXX_STR("Message"), 
spi::LocationInfo::getLocationUnavailable());
                LogString output;
                converter.format(e, output);
                LOGUNIT_ASSERT_EQUAL(LOG4CXX_STR(""), output);
   ```
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to