From 80ffcf3b1679cc1f48c04a88583c4673d3c2ea47 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 7 May 2014 20:47:28 +0200 Subject: Test that kconfig always uses native line endings in the created files --- autotests/kconfigtest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'autotests/kconfigtest.cpp') diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 2768318b..4f29ea87 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1626,6 +1626,24 @@ void KConfigTest::testAnonymousConfig() QCOMPARE(general.readEntry("Foo"), QString("Bar")); } +void KConfigTest::testNewlines() +{ + // test that kconfig always uses the native line endings + QTemporaryFile file; + file.open(); + KConfig anonConfig(file.fileName(), KConfig::SimpleConfig); + KConfigGroup general(&anonConfig, "General"); + general.writeEntry("Foo", "Bar"); + general.writeEntry("Bar", "Foo"); + anonConfig.sync(); +#ifndef Q_OS_WIN + QCOMPARE(file.readAll(), QByteArrayLiteral("[General]\nBar=Foo\nFoo=Bar\n")); +#else + QCOMPARE(file.readAll(), QByteArrayLiteral("[General]\r\nBar=Foo\r\nFoo=Bar\r\n")); +#endif + +} + #include #include -- cgit v1.2.1