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

[logging-log4cxx] branch LOGCXX-540 created (now 9bf4d0f)

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

rmiddleton pushed a change to branch LOGCXX-540
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git.


      at 9bf4d0f  LOGCXX-540 Updated test to explicitly check all line endings

This branch includes the following new commits:

     new 9bf4d0f  LOGCXX-540 Updated test to explicitly check all line endings

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[logging-log4cxx] 01/01: LOGCXX-540 Updated test to explicitly check all line endings

Posted by rm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9bf4d0f752a2d1b15247cc6fc0266fc9efaa49f0
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Fri Dec 17 22:32:01 2021 -0500

    LOGCXX-540 Updated test to explicitly check all line endings
---
 .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 1f372b3..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 1f372b3..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 1f372b3..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 1f372b3..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