From 4a07c8151ec8b0c62a34e9be84d172154da394ba Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Wed, 14 Nov 2018 11:10:34 +0100 Subject: [PATCH] Make sure errors are recognized in all sections, not just the first one --- tests/core/test_desktopfilereader.cpp | 60 +++++++++++++++++++++------ 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/tests/core/test_desktopfilereader.cpp b/tests/core/test_desktopfilereader.cpp index 906d688..7645d9a 100644 --- a/tests/core/test_desktopfilereader.cpp +++ b/tests/core/test_desktopfilereader.cpp @@ -203,25 +203,61 @@ TEST_F(DesktopFileReaderFixture, testParseLinesWithMultipleSpaces) { } TEST_F(DesktopFileReaderFixture, testReadBrokenSectionHeaderMissingClosingBracket) { - std::stringstream ins; - ins << "[Desktop Entry" << std::endl - << "test=test" << std::endl; + { + std::stringstream ins; + ins << "[Desktop Entry" << std::endl + << "test=test" << std::endl; - ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + } + + // also test for brokenness in a later section, as the first section is normally treated specially + { + std::stringstream ins; + ins << "[Desktop Entry]" << std::endl + << "test=test" << std::endl + << "[Another Section" << std::endl; + + ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + } } TEST_F(DesktopFileReaderFixture, testReadBrokenSectionHeaderTooManyClosingBrackets) { - std::stringstream ins; - ins << "[Desktop Entry]]" << std::endl - << "test=test" << std::endl; + { + std::stringstream ins; + ins << "[Desktop Entry]]" << std::endl + << "test=test" << std::endl; - ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + } + + // also test for brokenness in a later section, as the first section is normally treated specially + { + std::stringstream ins; + ins << "[Desktop Entry]" << std::endl + << "test=test" << std::endl + << "[Another Section]]" << std::endl; + + ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + } } TEST_F(DesktopFileReaderFixture, testReadBrokenSectionHeaderTooManyOpeningBrackets) { - std::stringstream ins; - ins << "[[Desktop Entry]" << std::endl - << "test=test" << std::endl; + { + std::stringstream ins; + ins << "[[Desktop Entry]" << std::endl + << "test=test" << std::endl; - ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + } + + // also test for brokenness in a later section, as the first section is normally treated specially + { + std::stringstream ins; + ins << "[Desktop Entry]" << std::endl + << "test=test" << std::endl + << "[[Another Section]"; + + ASSERT_THROW(DesktopFileReader reader(ins), ParseError); + } }