diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-04-28 01:23:00 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-28 22:29:45 +0200 |
commit | 8250e1a4a3f103bf37ca09c8dbab0584a5a1c2cf (patch) | |
tree | 41b5522c33dfa51d5cbbc9de108b3cdf1b586191 /tools/qa | |
parent | b1ade4efa12740dd7c9cc4ab73836d65470ed16b (diff) |
use std container for ParameterList
'ParameterList::find' was used to detect duplicate sections and
sort the parameters by attribute and section.
Checking for duplicates is done by 'std::any_of' and
the predicate 'Parameter::IsSameSection' now.
The parameters are inserted as they are parsed and sorted later
with 'std::sort' algorithm and 'Parameter::operator<'
Adapt loops to use iterators. Change a weird 'for' loop in
'parseParameters' to a 'do .. while ..' loop to match style of a
preceding loop.
Extend unit test with a case of duplicate sections.
Change-Id: If2789c0cee8f64deae84bc720807d2d26d81dc9f
Reviewed-on: https://gerrit.libreoffice.org/37075
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools/qa')
-rw-r--r-- | tools/qa/cppunit/test_inetmime.cxx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/qa/cppunit/test_inetmime.cxx b/tools/qa/cppunit/test_inetmime.cxx index 8b953526778c..f41b72850bf0 100644 --- a/tools/qa/cppunit/test_inetmime.cxx +++ b/tools/qa/cppunit/test_inetmime.cxx @@ -130,16 +130,18 @@ namespace input = "TEST/subTST;" "parm1*0*=us-ascii'en'value;PARM1*1*=1;" "parm2*0*=WINDOWS-1250'en-GB'value2%20%80;" - "parm3*0*=UNKNOWN'EN'value3"; + "parm3*0*=UNKNOWN'EN'value3;" + "parm1*1*=2"; // this parameter is a duplicate, + // the scan should end before this parameter // Just scan input for valid string: end = INetMIME::scanContentType(input.getStr(), input.getStr()+input.getLength()); CPPUNIT_ASSERT(end != nullptr); - CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end)); + CPPUNIT_ASSERT_EQUAL(OUString(";parm1*1*=2"), OUString(end)); // the invalid end of input // Scan input and parse type, subType and parameters: end = INetMIME::scanContentType(input.getStr(), input.getStr() + input.getLength(), &type, &subType, ¶meters); CPPUNIT_ASSERT(end != nullptr); - CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end)); + CPPUNIT_ASSERT_EQUAL(OUString(";parm1*1*=2"), OUString(end)); // the invalid end of input CPPUNIT_ASSERT_EQUAL(OUString("test"), type); CPPUNIT_ASSERT_EQUAL(OUString("subtst"), subType); CPPUNIT_ASSERT_EQUAL( |