diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-30 19:35:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-03 08:41:11 +0200 |
commit | d3971ec256450e6783920b46f672048b29719949 (patch) | |
tree | f4722d0e2bc321cf71b49b7573cf38640e9b28fc /tools/qa | |
parent | f50bf3c5225b49b3c6f77f882e35305e5dc5ccd3 (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')
-rw-r--r-- | tools/qa/cppunit/test_color.cxx | 20 | ||||
-rw-r--r-- | tools/qa/cppunit/test_inetmime.cxx | 198 |
2 files changed, 106 insertions, 112 deletions
diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx index d0f0e173f9a7..dc89226fb3f7 100644 --- a/tools/qa/cppunit/test_color.cxx +++ b/tools/qa/cppunit/test_color.cxx @@ -61,21 +61,19 @@ void Test::test_asRGBColor() void Test::test_readAndWriteStream() { - { - SvMemoryStream aStream; - Color aWriteColor(0x12, 0x34, 0x56); - Color aReadColor; + SvMemoryStream aStream; + Color aWriteColor(0x12, 0x34, 0x56); + Color aReadColor; - WriteColor(aStream, aWriteColor); + WriteColor(aStream, aWriteColor); - aStream.Seek(STREAM_SEEK_TO_BEGIN); + aStream.Seek(STREAM_SEEK_TO_BEGIN); - ReadColor(aStream, aReadColor); + ReadColor(aStream, aReadColor); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x12), aReadColor.GetRed()); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x34), aReadColor.GetGreen()); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x56), aReadColor.GetBlue()); - } + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x12), aReadColor.GetRed()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x34), aReadColor.GetGreen()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x56), aReadColor.GetBlue()); } OUString createTintShade(sal_uInt8 nR, sal_uInt8 nG, sal_uInt8 nB, OUString const & sReference, sal_Int16 nTintShade) 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, ¶meters); - 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, ¶meters); + 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, ¶meters); - 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, ¶meters); + 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, ¶meters); - 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, ¶meters); + 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); |