You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ts...@apache.org on 2021/12/18 11:07:52 UTC

[logging-log4cxx] branch master updated: LOGCXX-540 Updated test to explicitly check all line endings (#85)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9c455fc  LOGCXX-540 Updated test to explicitly check all line endings (#85)
9c455fc is described below

commit 9c455fc91e0dd3cf9b0ab7c79571536128347999
Author: Robert Middleton <rm...@users.noreply.github.com>
AuthorDate: Sat Dec 18 06:07:48 2021 -0500

    LOGCXX-540 Updated test to explicitly check all line endings (#85)
    
    Co-authored-by: Thorsten Schöning <62...@users.noreply.github.com>
---
 .gitattributes                                     |  6 +++
 src/test/cpp/helpers/propertiestestcase.cpp        | 61 +++++++++++++++++-----
 ...operties => propertiestestcase-crlf.properties} | 21 ++------
 ...properties => propertiestestcase-lf.properties} | 21 ++------
 ...perties => propertiestestcase-mixed.properties} | 20 ++-----
 .../resources/input/propertiestestcase.properties  |  2 +-
 6 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index 2a49125..d9bd095 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -5,3 +5,9 @@
 # This is a windows-specific file
 src/main/resources/log4cxx.rc eol=crlf
 
+# These files have specific line endings to ensure that they work
+# correctly on all platforms
+src/test/resources/input/propertiestestcase.properties eol=auto
+src/test/resources/input/propertiestestcase-crlf.properties eol=crlf
+src/test/resources/input/propertiestestcase-lf.properties eol=lf
+src/test/resources/input/propertiestestcase-mixed.properties -text
diff --git a/src/test/cpp/helpers/propertiestestcase.cpp b/src/test/cpp/helpers/propertiestestcase.cpp
index e19854b..315b6c8 100644
--- a/src/test/cpp/helpers/propertiestestcase.cpp
+++ b/src/test/cpp/helpers/propertiestestcase.cpp
@@ -35,13 +35,15 @@ LOGUNIT_CLASS(PropertiesTestCase)
 	LOGUNIT_TEST(testTab5);
 	LOGUNIT_TEST(testTab6);
 	LOGUNIT_TEST(testTab7);
-	LOGUNIT_TEST(testCRLF1);
 	LOGUNIT_TEST(testEscT1);
 	LOGUNIT_TEST(testEscT2);
 	LOGUNIT_TEST(testEscN1);
 	LOGUNIT_TEST(testEscN2);
 	LOGUNIT_TEST(testEscR1);
 	LOGUNIT_TEST(testEscR2);
+	LOGUNIT_TEST(testCRLF);
+	LOGUNIT_TEST(testLF);
+	LOGUNIT_TEST(testMixedLineEndings);
 	LOGUNIT_TEST_SUITE_END();
 
 public:
@@ -153,19 +155,6 @@ public:
 	}
 
 	/**
-	 *  Test tab in value continuation, see LOGCXX-292.
-	*/
-	void testCRLF1()
-	{
-		FileInputStreamPtr propFile(
-			new FileInputStream(LOG4CXX_STR("input/propertiestestcase.properties")));
-		Properties properties;
-		properties.load(propFile);
-		LogString actual(properties.getProperty(LOG4CXX_STR("propertiestestcase.crlf1")));
-		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("continuedvalue")), actual);
-	}
-
-	/**
 	 *  Test tab as escaped within key, see LOGCXX-293.
 	*/
 	void testEscT1()
@@ -261,6 +250,50 @@ public:
 		LOGUNIT_ASSERT_EQUAL(expected, actual);
 	}
 
+	void testCRLF(){
+		FileInputStreamPtr propFile(
+			new FileInputStream(LOG4CXX_STR("input/propertiestestcase-crlf.properties")));
+		Properties properties;
+		properties.load(propFile);
+
+		LogString value1(properties.getProperty(LOG4CXX_STR("propertiestestcase.value1")));
+		LogString value2(properties.getProperty(LOG4CXX_STR("propertiestestcase.value2")));
+		LogString value3(properties.getProperty(LOG4CXX_STR("propertiestestcase.value3")));
+
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("hi this is a test")), value1);
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("multiline")), value2);
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("some_value")), value3);
+	}
+
+	void testLF(){
+		FileInputStreamPtr propFile(
+			new FileInputStream(LOG4CXX_STR("input/propertiestestcase-lf.properties")));
+		Properties properties;
+		properties.load(propFile);
+
+		LogString value1(properties.getProperty(LOG4CXX_STR("propertiestestcase.value1")));
+		LogString value2(properties.getProperty(LOG4CXX_STR("propertiestestcase.value2")));
+		LogString value3(properties.getProperty(LOG4CXX_STR("propertiestestcase.value3")));
+
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("hi this is a test")), value1);
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("multiline")), value2);
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("some_value")), value3);
+	}
+
+	void testMixedLineEndings(){
+		FileInputStreamPtr propFile(
+			new FileInputStream(LOG4CXX_STR("input/propertiestestcase-mixed.properties")));
+		Properties properties;
+		properties.load(propFile);
+
+		LogString value1(properties.getProperty(LOG4CXX_STR("propertiestestcase.value1")));
+		LogString value2(properties.getProperty(LOG4CXX_STR("propertiestestcase.value2")));
+		LogString value3(properties.getProperty(LOG4CXX_STR("propertiestestcase.value3")));
+
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("hi this is a test")), value1);
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("something")), value2);
+		LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("some_value")), value3);
+	}
 
 };
 
diff --git a/src/test/resources/input/propertiestestcase.properties b/src/test/resources/input/propertiestestcase-crlf.properties
similarity index 57%
copy from src/test/resources/input/propertiestestcase.properties
copy to src/test/resources/input/propertiestestcase-crlf.properties
index c47f827..3ae6f63 100644
--- a/src/test/resources/input/propertiestestcase.properties
+++ b/src/test/resources/input/propertiestestcase-crlf.properties
@@ -13,20 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-propertiestestcase.tab1	tab delimited
-	propertiestestcase.tab2=tab before key
-propertiestestcase.tab3\	=key contains tab
-propertiestestcase.tab4=	tab after equals
-propertiestestcase\
-	.tab5=tab after continue
-propertiestestcase.tab6=\	 in value
-propertiestestcase.tab7=continued\
-	value
-propertiestestcase.crlf1=continued\
- value
-propertiestestcase.esct1\t=key contains tab
-propertiestestcase.esct2=\t in value
-propertiestestcase.escn1\n=key contains lf
-propertiestestcase.escn2=\n in value
-propertiestestcase.escr1\r=key contains cr
-propertiestestcase.escr2=\r in value
+propertiestestcase.value1=hi this is a test
+propertiestestcase.value2=multi\
+ line
+propertiestestcase.value3=some_value
diff --git a/src/test/resources/input/propertiestestcase.properties b/src/test/resources/input/propertiestestcase-lf.properties
similarity index 57%
copy from src/test/resources/input/propertiestestcase.properties
copy to src/test/resources/input/propertiestestcase-lf.properties
index c47f827..3ae6f63 100644
--- a/src/test/resources/input/propertiestestcase.properties
+++ b/src/test/resources/input/propertiestestcase-lf.properties
@@ -13,20 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-propertiestestcase.tab1	tab delimited
-	propertiestestcase.tab2=tab before key
-propertiestestcase.tab3\	=key contains tab
-propertiestestcase.tab4=	tab after equals
-propertiestestcase\
-	.tab5=tab after continue
-propertiestestcase.tab6=\	 in value
-propertiestestcase.tab7=continued\
-	value
-propertiestestcase.crlf1=continued\
- value
-propertiestestcase.esct1\t=key contains tab
-propertiestestcase.esct2=\t in value
-propertiestestcase.escn1\n=key contains lf
-propertiestestcase.escn2=\n in value
-propertiestestcase.escr1\r=key contains cr
-propertiestestcase.escr2=\r in value
+propertiestestcase.value1=hi this is a test
+propertiestestcase.value2=multi\
+ line
+propertiestestcase.value3=some_value
diff --git a/src/test/resources/input/propertiestestcase.properties b/src/test/resources/input/propertiestestcase-mixed.properties
similarity index 57%
copy from src/test/resources/input/propertiestestcase.properties
copy to src/test/resources/input/propertiestestcase-mixed.properties
index c47f827..c43b9d7 100644
--- a/src/test/resources/input/propertiestestcase.properties
+++ b/src/test/resources/input/propertiestestcase-mixed.properties
@@ -13,20 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-propertiestestcase.tab1	tab delimited
-	propertiestestcase.tab2=tab before key
-propertiestestcase.tab3\	=key contains tab
-propertiestestcase.tab4=	tab after equals
-propertiestestcase\
-	.tab5=tab after continue
-propertiestestcase.tab6=\	 in value
-propertiestestcase.tab7=continued\
-	value
-propertiestestcase.crlf1=continued\
- value
-propertiestestcase.esct1\t=key contains tab
-propertiestestcase.esct2=\t in value
-propertiestestcase.escn1\n=key contains lf
-propertiestestcase.escn2=\n in value
-propertiestestcase.escr1\r=key contains cr
-propertiestestcase.escr2=\r in value
+propertiestestcase.value1=hi this is a test
+propertiestestcase.value2=something
+propertiestestcase.value3=some_value
diff --git a/src/test/resources/input/propertiestestcase.properties b/src/test/resources/input/propertiestestcase.properties
index c47f827..5edcb52 100644
--- a/src/test/resources/input/propertiestestcase.properties
+++ b/src/test/resources/input/propertiestestcase.properties
@@ -22,7 +22,7 @@ propertiestestcase\
 propertiestestcase.tab6=\	 in value
 propertiestestcase.tab7=continued\
 	value
-propertiestestcase.crlf1=continued\
+propertiestestcase.continued=continued\
  value
 propertiestestcase.esct1\t=key contains tab
 propertiestestcase.esct2=\t in value