summaryrefslogtreecommitdiff
path: root/tools/qa/cppunit/test_inetmime.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-30 19:35:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-10-03 08:41:11 +0200
commitd3971ec256450e6783920b46f672048b29719949 (patch)
treef4722d0e2bc321cf71b49b7573cf38640e9b28fc /tools/qa/cppunit/test_inetmime.cxx
parentf50bf3c5225b49b3c6f77f882e35305e5dc5ccd3 (diff)
new loplugin:blockblock
Change-Id: I7b68b70fa4c7234e8882f7627026959a596968fd Reviewed-on: https://gerrit.libreoffice.org/43025 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools/qa/cppunit/test_inetmime.cxx')
-rw-r--r--tools/qa/cppunit/test_inetmime.cxx198
1 files changed, 97 insertions, 101 deletions
diff --git a/tools/qa/cppunit/test_inetmime.cxx b/tools/qa/cppunit/test_inetmime.cxx
index c28fa6885f99..61c5d45fa774 100644
--- a/tools/qa/cppunit/test_inetmime.cxx
+++ b/tools/qa/cppunit/test_inetmime.cxx
@@ -60,112 +60,108 @@ namespace
void Test::test_scanContentType_basic()
{
- {
- OUString input
- = "TEST/subTST; parm1=Value1; Parm2=\"unpacked value; %20\"";
- // Just scan input for valid string:
- auto end = INetMIME::scanContentType(input);
- CPPUNIT_ASSERT(end != nullptr);
- CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end));
- // Scan input and parse type, subType and parameters:
- OUString type;
- OUString subType;
- INetContentTypeParameterList parameters;
- end = INetMIME::scanContentType(input,
- &type, &subType, &parameters);
- CPPUNIT_ASSERT(end != nullptr);
- CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end));
- CPPUNIT_ASSERT_EQUAL(OUString("test"), type);
- CPPUNIT_ASSERT_EQUAL(OUString("subtst"), subType);
- CPPUNIT_ASSERT_EQUAL(
- INetContentTypeParameterList::size_type(2), parameters.size());
- auto i = parameters.find("parm1");
- CPPUNIT_ASSERT(i != parameters.end());
- CPPUNIT_ASSERT_EQUAL(OString(), i->second.m_sCharset);
- CPPUNIT_ASSERT_EQUAL(OString(), i->second.m_sLanguage);
- CPPUNIT_ASSERT_EQUAL(OUString("Value1"), i->second.m_sValue);
- CPPUNIT_ASSERT(i->second.m_bConverted);
- i = parameters.find("parm2");
- CPPUNIT_ASSERT(i != parameters.end());
- CPPUNIT_ASSERT_EQUAL(OString(), i->second.m_sCharset);
- CPPUNIT_ASSERT_EQUAL(OString(), i->second.m_sLanguage);
- CPPUNIT_ASSERT_EQUAL(OUString("unpacked value; %20"), i->second.m_sValue);
- CPPUNIT_ASSERT(i->second.m_bConverted);
- }
+ OUString input
+ = "TEST/subTST; parm1=Value1; Parm2=\"unpacked value; %20\"";
+ // Just scan input for valid string:
+ auto end = INetMIME::scanContentType(input);
+ CPPUNIT_ASSERT(end != nullptr);
+ CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end));
+ // Scan input and parse type, subType and parameters:
+ OUString type;
+ OUString subType;
+ INetContentTypeParameterList parameters;
+ end = INetMIME::scanContentType(input,
+ &type, &subType, &parameters);
+ CPPUNIT_ASSERT(end != nullptr);
+ CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end));
+ CPPUNIT_ASSERT_EQUAL(OUString("test"), type);
+ CPPUNIT_ASSERT_EQUAL(OUString("subtst"), subType);
+ CPPUNIT_ASSERT_EQUAL(
+ INetContentTypeParameterList::size_type(2), parameters.size());
+ auto i = parameters.find("parm1");
+ CPPUNIT_ASSERT(i != parameters.end());
+ CPPUNIT_ASSERT_EQUAL(OString(), i->second.m_sCharset);
+ CPPUNIT_ASSERT_EQUAL(OString(), i->second.m_sLanguage);
+ CPPUNIT_ASSERT_EQUAL(OUString("Value1"), i->second.m_sValue);
+ CPPUNIT_ASSERT(i->second.m_bConverted);
+ i = parameters.find("parm2");
+ CPPUNIT_ASSERT(i != parameters.end());
+ CPPUNIT_ASSERT_EQUAL(OString(), i->second.m_sCharset);
+ CPPUNIT_ASSERT_EQUAL(OString(), i->second.m_sLanguage);
+ CPPUNIT_ASSERT_EQUAL(OUString("unpacked value; %20"), i->second.m_sValue);
+ CPPUNIT_ASSERT(i->second.m_bConverted);
}
void Test::test_scanContentType_rfc2231()
{
- {
- // Test extended parameter with value split in 3 sections:
- OUString input
- = "TEST/subTST; "
- "parm1*0*=US-ASCII'En'5%25%20; "
- "Parm1*1*=of%2010;\t"
- "parm1*2*=%20%3d%200.5";
- // Just scan input for valid string:
- auto end = INetMIME::scanContentType(input);
- CPPUNIT_ASSERT(end != nullptr);
- CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end));
- // Scan input and parse type, subType and parameters:
- OUString type;
- OUString subType;
- INetContentTypeParameterList parameters;
- end = INetMIME::scanContentType(input,
- &type, &subType, &parameters);
- CPPUNIT_ASSERT(end != nullptr);
- CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end));
- CPPUNIT_ASSERT_EQUAL(OUString("test"), type);
- CPPUNIT_ASSERT_EQUAL(OUString("subtst"), subType);
- CPPUNIT_ASSERT_EQUAL(
- INetContentTypeParameterList::size_type(1), parameters.size());
- auto i = parameters.find("parm1");
- CPPUNIT_ASSERT(i != parameters.end());
- CPPUNIT_ASSERT_EQUAL(OString("us-ascii"), i->second.m_sCharset);
- CPPUNIT_ASSERT_EQUAL(OString("en"), i->second.m_sLanguage);
- CPPUNIT_ASSERT_EQUAL(OUString("5% of 10 = 0.5"), i->second.m_sValue);
- CPPUNIT_ASSERT(i->second.m_bConverted);
+ // Test extended parameter with value split in 3 sections:
+ OUString input
+ = "TEST/subTST; "
+ "parm1*0*=US-ASCII'En'5%25%20; "
+ "Parm1*1*=of%2010;\t"
+ "parm1*2*=%20%3d%200.5";
+ // Just scan input for valid string:
+ auto end = INetMIME::scanContentType(input);
+ CPPUNIT_ASSERT(end != nullptr);
+ CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end));
+ // Scan input and parse type, subType and parameters:
+ OUString type;
+ OUString subType;
+ INetContentTypeParameterList parameters;
+ end = INetMIME::scanContentType(input,
+ &type, &subType, &parameters);
+ CPPUNIT_ASSERT(end != nullptr);
+ CPPUNIT_ASSERT_EQUAL(OUString(), OUString(end));
+ CPPUNIT_ASSERT_EQUAL(OUString("test"), type);
+ CPPUNIT_ASSERT_EQUAL(OUString("subtst"), subType);
+ CPPUNIT_ASSERT_EQUAL(
+ INetContentTypeParameterList::size_type(1), parameters.size());
+ auto i = parameters.find("parm1");
+ CPPUNIT_ASSERT(i != parameters.end());
+ CPPUNIT_ASSERT_EQUAL(OString("us-ascii"), i->second.m_sCharset);
+ CPPUNIT_ASSERT_EQUAL(OString("en"), i->second.m_sLanguage);
+ CPPUNIT_ASSERT_EQUAL(OUString("5% of 10 = 0.5"), i->second.m_sValue);
+ CPPUNIT_ASSERT(i->second.m_bConverted);
- // Test extended parameters with different value charsets:
- 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;"
- "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);
- CPPUNIT_ASSERT(end != nullptr);
- 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,
- &type, &subType, &parameters);
- CPPUNIT_ASSERT(end != nullptr);
- 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(
- INetContentTypeParameterList::size_type(3), parameters.size());
- i = parameters.find("parm1");
- CPPUNIT_ASSERT(i != parameters.end());
- CPPUNIT_ASSERT_EQUAL(OString("us-ascii"), i->second.m_sCharset);
- CPPUNIT_ASSERT_EQUAL(OString("en"), i->second.m_sLanguage);
- CPPUNIT_ASSERT_EQUAL(OUString("value1"), i->second.m_sValue);
- CPPUNIT_ASSERT(i->second.m_bConverted);
- i = parameters.find("parm2");
- CPPUNIT_ASSERT(i != parameters.end());
- CPPUNIT_ASSERT_EQUAL(OString("windows-1250"), i->second.m_sCharset);
- CPPUNIT_ASSERT_EQUAL(OString("en-gb"), i->second.m_sLanguage);
- // Euro currency sign, windows-1250 x80 is converted to unicode u20AC:
- CPPUNIT_ASSERT_EQUAL(OUString(u"value2 \u20AC"), i->second.m_sValue);
- CPPUNIT_ASSERT(i->second.m_bConverted);
- i = parameters.find("parm3");
- CPPUNIT_ASSERT(i != parameters.end());
- CPPUNIT_ASSERT_EQUAL(OString("unknown"), i->second.m_sCharset);
- CPPUNIT_ASSERT_EQUAL(OString("en"), i->second.m_sLanguage);
- // Conversion fails for unknown charsets:
- CPPUNIT_ASSERT(!i->second.m_bConverted);
- }
+ // Test extended parameters with different value charsets:
+ 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;"
+ "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);
+ CPPUNIT_ASSERT(end != nullptr);
+ 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,
+ &type, &subType, &parameters);
+ CPPUNIT_ASSERT(end != nullptr);
+ 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(
+ INetContentTypeParameterList::size_type(3), parameters.size());
+ i = parameters.find("parm1");
+ CPPUNIT_ASSERT(i != parameters.end());
+ CPPUNIT_ASSERT_EQUAL(OString("us-ascii"), i->second.m_sCharset);
+ CPPUNIT_ASSERT_EQUAL(OString("en"), i->second.m_sLanguage);
+ CPPUNIT_ASSERT_EQUAL(OUString("value1"), i->second.m_sValue);
+ CPPUNIT_ASSERT(i->second.m_bConverted);
+ i = parameters.find("parm2");
+ CPPUNIT_ASSERT(i != parameters.end());
+ CPPUNIT_ASSERT_EQUAL(OString("windows-1250"), i->second.m_sCharset);
+ CPPUNIT_ASSERT_EQUAL(OString("en-gb"), i->second.m_sLanguage);
+ // Euro currency sign, windows-1250 x80 is converted to unicode u20AC:
+ CPPUNIT_ASSERT_EQUAL(OUString(u"value2 \u20AC"), i->second.m_sValue);
+ CPPUNIT_ASSERT(i->second.m_bConverted);
+ i = parameters.find("parm3");
+ CPPUNIT_ASSERT(i != parameters.end());
+ CPPUNIT_ASSERT_EQUAL(OString("unknown"), i->second.m_sCharset);
+ CPPUNIT_ASSERT_EQUAL(OString("en"), i->second.m_sLanguage);
+ // Conversion fails for unknown charsets:
+ CPPUNIT_ASSERT(!i->second.m_bConverted);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);