Kaydet (Commit) 23b08449 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin: look for CPPUNIT_ASSERT_EQUALS with params swapped

idea originally from either tml or moggi, can't remember which

Change-Id: Id78d75035036d3aa1666e33469c6eeb38f9e624d
Reviewed-on: https://gerrit.libreoffice.org/55126Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 8e63d451
......@@ -271,7 +271,7 @@ void testErrorBar( Reference< XPropertySet > const & xErrorBar )
sal_Int32 nErrorBarStyle;
CPPUNIT_ASSERT(
xErrorBar->getPropertyValue("ErrorBarStyle") >>= nErrorBarStyle);
CPPUNIT_ASSERT_EQUAL(nErrorBarStyle, chart::ErrorBarStyle::RELATIVE);
CPPUNIT_ASSERT_EQUAL(chart::ErrorBarStyle::RELATIVE, nErrorBarStyle);
bool bShowPositive = bool(), bShowNegative = bool();
CPPUNIT_ASSERT(
xErrorBar->getPropertyValue("ShowPositiveError") >>= bShowPositive);
......
......@@ -245,11 +245,11 @@ void Chart2ImportTest::Fdo60083()
bool bVal;
CPPUNIT_ASSERT(
xErrorBarYProps->getPropertyValue("ShowPositiveError") >>= bVal);
CPPUNIT_ASSERT_EQUAL(bVal, true);
CPPUNIT_ASSERT_EQUAL(true, bVal);
CPPUNIT_ASSERT(
xErrorBarYProps->getPropertyValue("ShowNegativeError") >>= bVal);
CPPUNIT_ASSERT_EQUAL(bVal, true);
CPPUNIT_ASSERT_EQUAL(true, bVal);
}
// test that x error bars are not imported
......@@ -285,7 +285,7 @@ void Chart2ImportTest::testErrorBarRange()
OUString aRangePos;
CPPUNIT_ASSERT(xErrorBarYProps->getPropertyValue("ErrorBarRangePositive") >>= aRangePos);
CPPUNIT_ASSERT_EQUAL(aRangePos, OUString("$Sheet1.$C$2:$C$4"));
CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$C$2:$C$4"), aRangePos);
}
void Chart2ImportTest::testErrorBarFormatting()
......@@ -696,7 +696,7 @@ void Chart2ImportTest::testBnc889755()
uno::Reference< chart2::XInternalDataProvider > xDataProvider( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
uno::Reference< chart::XChartDataArray > xChartDataArray(xDataProvider, uno::UNO_QUERY_THROW);
uno::Sequence< OUString > aRowLabels = xChartDataArray->getRowDescriptions();
CPPUNIT_ASSERT_EQUAL( aRowLabels.getLength(), sal_Int32(16) );
CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aRowLabels.getLength());
CPPUNIT_ASSERT_EQUAL(OUString("Oct-12"), aRowLabels[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Nov-12"), aRowLabels[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Dec-12"), aRowLabels[2]);
......@@ -807,14 +807,14 @@ void Chart2ImportTest::testTdf105517()
long lineColor;
xPropSet1->getPropertyValue("Color") >>= lineColor;
// incorrect line color was 0x4a7ebb due to not handling themeOverride
CPPUNIT_ASSERT_EQUAL(lineColor, long(0xeaa700));
CPPUNIT_ASSERT_EQUAL(long(0xeaa700), lineColor);
Reference<beans::XPropertySet> xPropSet2(xDSContainer->getDataSeries()[1], uno::UNO_QUERY);
CPPUNIT_ASSERT(xPropSet2.is());
xPropSet2->getPropertyValue("Color") >>= lineColor;
// incorrect line color was 0x98b855
CPPUNIT_ASSERT_EQUAL(lineColor, long(0x1e69a8));
CPPUNIT_ASSERT_EQUAL(long(0x1e69a8), lineColor);
}
void Chart2ImportTest::testTdf106217()
......@@ -829,14 +829,14 @@ void Chart2ImportTest::testTdf106217()
CPPUNIT_ASSERT(xCircle.is());
uno::Reference<container::XNamed> xNamedShape(xCircle, uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(xNamedShape->getName(), OUString("Oval 1"));
CPPUNIT_ASSERT_EQUAL(OUString("Oval 1"), xNamedShape->getName());
awt::Point aPosition = xCircle->getPosition();
CPPUNIT_ASSERT_EQUAL(aPosition.X, sal_Int32(6870));
CPPUNIT_ASSERT_EQUAL(aPosition.Y, sal_Int32(7261));
CPPUNIT_ASSERT_EQUAL(sal_Int32(6870), aPosition.X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(7261), aPosition.Y);
awt::Size aSize = xCircle->getSize();
CPPUNIT_ASSERT_EQUAL(aSize.Width, sal_Int32(2701));
CPPUNIT_ASSERT_EQUAL(aSize.Height, sal_Int32(2700));
CPPUNIT_ASSERT_EQUAL(sal_Int32(2701), aSize.Width);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2700), aSize.Height);
}
void Chart2ImportTest::testTransparentBackground(OUString const & filename)
......@@ -1054,7 +1054,7 @@ void Chart2ImportTest::testSmoothDefaultValue2007XLSX()
chart2::CurveStyle eCurveStyle;
xPropSet->getPropertyValue("CurveStyle") >>= eCurveStyle;
CPPUNIT_ASSERT_EQUAL(eCurveStyle, chart2::CurveStyle_LINES);
CPPUNIT_ASSERT_EQUAL(chart2::CurveStyle_LINES, eCurveStyle);
}
void Chart2ImportTest::testSmoothDefaultValue2013XLSX()
......
......@@ -112,7 +112,7 @@ namespace comphelper_ifcontainer
std::vector< Reference< XInterface > > aElements = pContainer->getElements();
CPPUNIT_ASSERT_EQUAL_MESSAGE("query contents",
static_cast<int>(aElements.size()), nTests);
nTests, static_cast<int>(aElements.size()));
if (static_cast<int>(aElements.size()) == nTests)
{
for (i = 0; i < nTests; i++)
......
......@@ -75,13 +75,13 @@ void TestString::testDecimalStringToNumber()
void TestString::testIsdigitAsciiString()
{
OString s1("1234");
CPPUNIT_ASSERT_EQUAL(comphelper::string::isdigitAsciiString(s1), true);
CPPUNIT_ASSERT_EQUAL(true, comphelper::string::isdigitAsciiString(s1));
OString s2("1A34");
CPPUNIT_ASSERT_EQUAL(comphelper::string::isdigitAsciiString(s2), false);
CPPUNIT_ASSERT_EQUAL(false, comphelper::string::isdigitAsciiString(s2));
OString s3;
CPPUNIT_ASSERT_EQUAL(comphelper::string::isdigitAsciiString(s3), true);
CPPUNIT_ASSERT_EQUAL(true, comphelper::string::isdigitAsciiString(s3));
}
using namespace ::com::sun::star;
......
......@@ -10,9 +10,12 @@
#include "plugin.hxx"
#include "check.hxx"
#include "compat.hxx"
#include <iostream>
/**
Check for calls to CPPUNIT_ASSERT when it should be using CPPUNIT_ASSERT_EQUALS
Check for
(*) calls to CPPUNIT_ASSERT when it should be using CPPUNIT_ASSERT_EQUALS
(*) calls to CPPUNIT_ASSERT_EQUALS where the constant is the second param
*/
namespace {
......@@ -38,69 +41,131 @@ private:
SourceRange range, StringRef name, Expr const * expr, bool negated);
void reportEquals(SourceRange range, StringRef name, bool negative);
bool isCompileTimeConstant(Expr const * expr);
};
bool CppunitAssertEquals::VisitCallExpr(const CallExpr* callExpr)
{
auto const decl = callExpr->getDirectCallee();
if (decl == nullptr
|| !(loplugin::DeclCheck(decl).Function("failIf").Struct("Asserter")
.Namespace("CppUnit").GlobalNamespace()))
{
if (!decl)
return true;
/*
calls to CPPUNIT_ASSERT when it should be using CPPUNIT_ASSERT_EQUALS
*/
if (loplugin::DeclCheck(decl).Function("failIf").Struct("Asserter")
.Namespace("CppUnit").GlobalNamespace())
{
// Don't use callExpr->getLocStart() or callExpr->getExprLoc(), as those
// fall into a nested use of the CPPUNIT_NS macro; CallExpr::getRParenLoc
// happens to be readily available and cause good results:
auto loc = callExpr->getRParenLoc();
while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
}
if (!compiler.getSourceManager().isMacroBodyExpansion(loc)
|| ignoreLocation(
compiler.getSourceManager().getImmediateMacroCallerLoc(loc)))
{
return true;
}
auto name = Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(), compiler.getLangOpts());
if (name != "CPPUNIT_ASSERT" && name != "CPPUNIT_ASSERT_MESSAGE") {
return true;
}
if (decl->getNumParams() != 3) {
report(
DiagnosticsEngine::Warning,
("TODO: suspicious CppUnit::Asserter::failIf call with %0"
" parameters"),
callExpr->getExprLoc())
<< decl->getNumParams() << callExpr->getSourceRange();
return true;
}
auto const e1 = callExpr->getArg(0)->IgnoreParenImpCasts();
Expr const * e2 = nullptr;
if (auto const e3 = dyn_cast<UnaryOperator>(e1)) {
if (e3->getOpcode() == UO_LNot) {
e2 = e3->getSubExpr();
}
} else if (auto const e4 = dyn_cast<CXXOperatorCallExpr>(e1)) {
if (e4->getOperator() == OO_Exclaim) {
e2 = e4->getArg(0);
}
}
if (e2 == nullptr) {
report(
DiagnosticsEngine::Warning,
("TODO: suspicious CppUnit::Asserter::failIf call not wrapping"
" !(...)"),
callExpr->getExprLoc())
<< callExpr->getSourceRange();
return true;
}
auto range = compat::getImmediateExpansionRange(compiler.getSourceManager(), loc);
checkExpr(
SourceRange(range.first, range.second), name,
e2->IgnoreParenImpCasts(), false);
}
// Don't use callExpr->getLocStart() or callExpr->getExprLoc(), as those
// fall into a nested use of the CPPUNIT_NS macro; CallExpr::getRParenLoc
// happens to be readily available and cause good results:
auto loc = callExpr->getRParenLoc();
while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
}
if (!compiler.getSourceManager().isMacroBodyExpansion(loc)
|| ignoreLocation(
compiler.getSourceManager().getImmediateMacroCallerLoc(loc)))
/**
Check for calls to CPPUNIT_ASSERT_EQUALS where the constant is the second param
*/
if (loplugin::DeclCheck(decl).Function("assertEquals").
Namespace("CppUnit").GlobalNamespace())
{
return true;
// can happen in template test code that both params are compile time constants
if (isCompileTimeConstant(callExpr->getArg(0)))
return true;
if (isCompileTimeConstant(callExpr->getArg(1)))
report(
DiagnosticsEngine::Warning,
"CPPUNIT_ASSERT_EQUALS parameters look switched, expected value should be first param",
callExpr->getExprLoc())
<< callExpr->getSourceRange();
}
auto name = Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(), compiler.getLangOpts());
if (name != "CPPUNIT_ASSERT" && name != "CPPUNIT_ASSERT_MESSAGE") {
return true;
return true;
}
// copied from stringconcat.cxx
Expr const * stripCtor(Expr const * expr) {
auto e0 = expr;
auto const e1 = dyn_cast<CXXFunctionalCastExpr>(e0);
if (e1 != nullptr) {
e0 = e1->getSubExpr()->IgnoreParenImpCasts();
}
if (decl->getNumParams() != 3) {
report(
DiagnosticsEngine::Warning,
("TODO: suspicious CppUnit::Asserter::failIf call with %0"
" parameters"),
callExpr->getExprLoc())
<< decl->getNumParams() << callExpr->getSourceRange();
return true;
auto const e2 = dyn_cast<CXXBindTemporaryExpr>(e0);
if (e2 == nullptr) {
return expr;
}
auto const e1 = callExpr->getArg(0)->IgnoreParenImpCasts();
Expr const * e2 = nullptr;
if (auto const e3 = dyn_cast<UnaryOperator>(e1)) {
if (e3->getOpcode() == UO_LNot) {
e2 = e3->getSubExpr();
}
} else if (auto const e4 = dyn_cast<CXXOperatorCallExpr>(e1)) {
if (e4->getOperator() == OO_Exclaim) {
e2 = e4->getArg(0);
}
auto const e3 = dyn_cast<CXXConstructExpr>(
e2->getSubExpr()->IgnoreParenImpCasts());
if (e3 == nullptr) {
return expr;
}
if (e2 == nullptr) {
report(
DiagnosticsEngine::Warning,
("TODO: suspicious CppUnit::Asserter::failIf call not wrapping"
" !(...)"),
callExpr->getExprLoc())
<< callExpr->getSourceRange();
return true;
auto qt = loplugin::DeclCheck(e3->getConstructor());
if (!((qt.MemberFunction().Class("OString").Namespace("rtl")
.GlobalNamespace())
|| (qt.MemberFunction().Class("OUString").Namespace("rtl")
.GlobalNamespace())))
{
return expr;
}
auto range = compat::getImmediateExpansionRange(compiler.getSourceManager(), loc);
checkExpr(
SourceRange(range.first, range.second), name,
e2->IgnoreParenImpCasts(), false);
return true;
if (e3->getNumArgs() != 2) {
return expr;
}
return e3->getArg(0)->IgnoreParenImpCasts();
}
bool CppunitAssertEquals::isCompileTimeConstant(Expr const * expr)
{
if (expr->isIntegerConstantExpr(compiler.getASTContext()))
return true;
// is string literal ?
expr = expr->IgnoreParenImpCasts();
expr = stripCtor(expr);
return isa<clang::StringLiteral>(expr);
}
void CppunitAssertEquals::checkExpr(
......
......@@ -9,7 +9,10 @@
#include "sal/config.h"
#include "cppunit/TestAssert.h"
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
#include "cppunitassertequals.hxx"
......@@ -51,6 +54,15 @@ void test(bool b1, bool b2, OUString const & s1, OUString const & s2, T t) {
CPPUNIT_ASSERT(bool(b1 && b2));
CPPUNIT_ASSERT(bool(b1 == b2));
CPPUNIT_ASSERT(bool(s1 == s2));
CPPUNIT_ASSERT_EQUAL(b1, true); // expected-error {{CPPUNIT_ASSERT_EQUALS parameters look switched, expected value should be first param [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT_EQUAL_MESSAGE("foo", b1, true); // expected-error {{CPPUNIT_ASSERT_EQUALS parameters look switched, expected value should be first param [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT_EQUAL(true, b1);
CPPUNIT_ASSERT_EQUAL_MESSAGE("foo", true, b1);
CPPUNIT_ASSERT_EQUAL(s1, OUString("xxx")); // expected-error {{CPPUNIT_ASSERT_EQUALS parameters look switched, expected value should be first param [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT_EQUAL_MESSAGE("foo", s1, OUString("xxx")); // expected-error {{CPPUNIT_ASSERT_EQUALS parameters look switched, expected value should be first param [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT_EQUAL(OUString("xxx"), s1);
CPPUNIT_ASSERT_EQUAL_MESSAGE("foo", OUString("xxx"), s1);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -418,30 +418,30 @@ void Test::testBigStruct() {
buffer[i] = '\x56';
}
Guard guard(buffer.get());
CPPUNIT_ASSERT_EQUAL(guard.p->m1, sal_False);
CPPUNIT_ASSERT_EQUAL(guard.p->m2, static_cast< sal_Int8 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m3, static_cast< sal_Int16 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m4, static_cast< sal_uInt16 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m5, static_cast< sal_Int32 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m6, static_cast< sal_uInt32 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m7, static_cast< sal_Int64 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m8, static_cast< sal_uInt64 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m9, 0.0f);
CPPUNIT_ASSERT_EQUAL(guard.p->m10, 0.0);
CPPUNIT_ASSERT_EQUAL(guard.p->m11, u'\0');
CPPUNIT_ASSERT_EQUAL(guard.p->m12.getLength(), static_cast< sal_Int32 >(0));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(guard.p->m13.getTypeClass()), sal_Int32(css::uno::TypeClass_VOID));
CPPUNIT_ASSERT_EQUAL(guard.p->m14.hasValue(), false);
CPPUNIT_ASSERT_EQUAL(guard.p->m15.getLength(), static_cast< sal_Int32 >(0));
CPPUNIT_ASSERT_EQUAL(static_cast<int>(guard.p->m16), int(test::codemaker::cppumaker::HelperEnum_ZERO));
CPPUNIT_ASSERT_EQUAL(guard.p->m17.m1, sal_False);
CPPUNIT_ASSERT_EQUAL(guard.p->m17.m2.is(), false);
CPPUNIT_ASSERT_EQUAL(guard.p->m18.is(), false);
CPPUNIT_ASSERT_EQUAL(guard.p->m19, static_cast< sal_Int8 >(0));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(guard.p->m20), sal_Int32(test::codemaker::cppumaker::HelperEnum_ZERO));
CPPUNIT_ASSERT_EQUAL(guard.p->m21.getLength(), static_cast< sal_Int32 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m22.getLength(), static_cast< sal_Int32 >(0));
CPPUNIT_ASSERT_EQUAL(guard.p->m23.getLength(), static_cast< sal_Int32 >(0));
CPPUNIT_ASSERT_EQUAL(sal_False, guard.p->m1);
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int8 >(0), guard.p->m2);
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int16 >(0), guard.p->m3);
CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt16 >(0), guard.p->m4);
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), guard.p->m5);
CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(0), guard.p->m6);
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int64 >(0), guard.p->m7);
CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt64 >(0), guard.p->m8);
CPPUNIT_ASSERT_EQUAL(0.0f, guard.p->m9);
CPPUNIT_ASSERT_EQUAL(0.0, guard.p->m10);
CPPUNIT_ASSERT_EQUAL( u'\0', guard.p->m11);
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), guard.p->m12.getLength());
CPPUNIT_ASSERT_EQUAL(sal_Int32(css::uno::TypeClass_VOID), static_cast<sal_Int32>(guard.p->m13.getTypeClass()));
CPPUNIT_ASSERT_EQUAL(false, guard.p->m14.hasValue());
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), guard.p->m15.getLength());
CPPUNIT_ASSERT_EQUAL(int(test::codemaker::cppumaker::HelperEnum_ZERO), static_cast<int>(guard.p->m16));
CPPUNIT_ASSERT_EQUAL(sal_False, guard.p->m17.m1);
CPPUNIT_ASSERT_EQUAL(false, guard.p->m17.m2.is());
CPPUNIT_ASSERT_EQUAL(false, guard.p->m18.is());
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int8 >(0), guard.p->m19);
CPPUNIT_ASSERT_EQUAL(sal_Int32(test::codemaker::cppumaker::HelperEnum_ZERO), static_cast<sal_Int32>(guard.p->m20));
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), guard.p->m21.getLength());
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), guard.p->m22.getLength());
CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), guard.p->m23.getLength());
//This is a very platform specific test.
#if defined __GNUC__ && __GNUC__ >= 3 // see CPPU_GCC3_ALIGN
......@@ -482,9 +482,9 @@ void Test::testPolyStruct() {
aEmptySequence;
CPPUNIT_ASSERT_EQUAL(
static_cast< sal_uInt32 >(5),
(test::codemaker::cppumaker::make_Struct< sal_uInt32, sal_Bool >(5,
aEmptySequence).member1),
static_cast< sal_uInt32 >(5));
aEmptySequence).member1));
}
void Test::testExceptions() {
......
......@@ -813,8 +813,8 @@ void DesktopLOKTest::testCommandResult()
std::stringstream aStream(m_aCommandResult.getStr());
boost::property_tree::read_json(aStream, aTree);
CPPUNIT_ASSERT_EQUAL(aTree.get_child("commandName").get_value<std::string>(), std::string(".uno:Bold"));
CPPUNIT_ASSERT_EQUAL(aTree.get_child("success").get_value<bool>(), true);
CPPUNIT_ASSERT_EQUAL(std::string(".uno:Bold"), aTree.get_child("commandName").get_value<std::string>());
CPPUNIT_ASSERT_EQUAL(true, aTree.get_child("success").get_value<bool>());
comphelper::LibreOfficeKit::setActive(false);
}
......@@ -909,7 +909,7 @@ void DesktopLOKTest::testSheetOperations()
"{ \"Index\": { \"type\": \"long\", \"value\": 3 } }", false);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(pDocument->pClass->getParts(pDocument), 6);
CPPUNIT_ASSERT_EQUAL(6, pDocument->pClass->getParts(pDocument));
std::vector<OString> aExpected = { "FirstSheet", "Renamed", "Sheet3", "Sheet4", "Sheet5", "LastSheet" };
for (int i = 0; i < 6; ++i)
......@@ -2242,7 +2242,7 @@ void DesktopLOKTest::testExtractParameter()
namespace {
size_t documentClassOffset(int i)
constexpr size_t documentClassOffset(int i)
{
return sizeof(static_cast<struct _LibreOfficeKitDocumentClass*>(nullptr)->nSize) + i * sizeof(void*);
}
......
......@@ -547,7 +547,7 @@ void TestLanguageTag::testAllTags()
LanguageTag qtx( s_qtx );
qtx.setScriptType( LanguageTag::ScriptType::RTL );
LanguageType n_qtx = qtx.getLanguageType();
CPPUNIT_ASSERT_EQUAL( MsLangId::getScriptType(n_qtx), css::i18n::ScriptType::COMPLEX );
CPPUNIT_ASSERT_EQUAL( css::i18n::ScriptType::COMPLEX, MsLangId::getScriptType(n_qtx) );
CPPUNIT_ASSERT( MsLangId::isRightToLeft(n_qtx) );
CPPUNIT_ASSERT( !MsLangId::isCJK(n_qtx) );
}
......
......@@ -80,7 +80,7 @@ void TestCharacterClassification::testStringType()
//simple case
OUString sTest("Some text");
sal_Int32 nResult = m_xCC->getStringType(sTest, 0, sTest.getLength(), aLocale);
CPPUNIT_ASSERT_EQUAL(nResult, sal_Int32(230));
CPPUNIT_ASSERT_EQUAL(sal_Int32(230), nResult);
}
{
......@@ -88,7 +88,7 @@ void TestCharacterClassification::testStringType()
const sal_Unicode MATHEMATICAL_ITALIC_SMALL_THETA[] = { 0xD835, 0xDF03 };
OUString sTest(MATHEMATICAL_ITALIC_SMALL_THETA, SAL_N_ELEMENTS(MATHEMATICAL_ITALIC_SMALL_THETA));
sal_Int32 nResult = m_xCC->getStringType(sTest, 0, sTest.getLength(), aLocale);
CPPUNIT_ASSERT_EQUAL(nResult, sal_Int32(228));
CPPUNIT_ASSERT_EQUAL(sal_Int32(228), nResult);
}
}
......
......@@ -111,25 +111,25 @@ public:
{
aTestObj1 = cow_wrapper_client1( 1 );
CPPUNIT_ASSERT_EQUAL(aTestObj1.queryUnmodified(), 1);
CPPUNIT_ASSERT_EQUAL(1, aTestObj1.queryUnmodified());
aTestObj2.modify( 2 );
CPPUNIT_ASSERT_EQUAL(aTestObj2.queryUnmodified(), 2);
CPPUNIT_ASSERT_EQUAL(2, aTestObj2.queryUnmodified());
aTestObj3.modify( 3 );
CPPUNIT_ASSERT_EQUAL(aTestObj3.queryUnmodified(), 3);
CPPUNIT_ASSERT_EQUAL(3, aTestObj3.queryUnmodified());
aTestObj4 = cow_wrapper_client2( 4 );
CPPUNIT_ASSERT_EQUAL(aTestObj4.queryUnmodified(), 4);
CPPUNIT_ASSERT_EQUAL(4, aTestObj4.queryUnmodified());
aTestObj5.modify( 5 );
CPPUNIT_ASSERT_EQUAL(aTestObj5.queryUnmodified(), 5);
CPPUNIT_ASSERT_EQUAL(5, aTestObj5.queryUnmodified());
aTestObj6.modify( 6 );
CPPUNIT_ASSERT_EQUAL(aTestObj6.queryUnmodified(), 6);
CPPUNIT_ASSERT_EQUAL(6, aTestObj6.queryUnmodified());
aTestObj7 = cow_wrapper_client3( 7 );
CPPUNIT_ASSERT_EQUAL(aTestObj7.queryUnmodified(), 7);
CPPUNIT_ASSERT_EQUAL(7, aTestObj7.queryUnmodified());
aTestObj8.modify( 8 );
CPPUNIT_ASSERT_EQUAL(aTestObj8.queryUnmodified(), 8);
CPPUNIT_ASSERT_EQUAL(8, aTestObj8.queryUnmodified());
aTestObj9.modify( 9 );
CPPUNIT_ASSERT_EQUAL(aTestObj9.queryUnmodified(), 9);
CPPUNIT_ASSERT_EQUAL(9, aTestObj9.queryUnmodified());
}
// all three temporaries are dead now
......
This diff is collapsed.
......@@ -504,7 +504,7 @@ namespace osl_Pipe
int nRet = aPipe.send( m_pTestString1.getStr(), 3 );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "#test comment#: use after close.",
nRet, OSL_PIPE_FAIL );
OSL_PIPE_FAIL, nRet );
}
CPPUNIT_TEST_SUITE( close );
......
......@@ -65,28 +65,28 @@ public:
'.', ',', &status, &end);
CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), end);
CPPUNIT_ASSERT_EQUAL(rtl::math::isNan(res), true);
CPPUNIT_ASSERT_EQUAL(true, rtl::math::isNan(res));
res = rtl::math::stringToDouble(
rtl::OUString("NaN1.23"),
'.', ',', &status, &end);
CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), end);
CPPUNIT_ASSERT_EQUAL(rtl::math::isNan(res), true);
CPPUNIT_ASSERT_EQUAL(true, rtl::math::isNan(res));
res = rtl::math::stringToDouble(
rtl::OUString("INF"),
'.', ',', &status, &end);
CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_OutOfRange, status);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), end);
CPPUNIT_ASSERT_EQUAL(rtl::math::isInf(res), true);
CPPUNIT_ASSERT_EQUAL(true, rtl::math::isInf(res));
res = rtl::math::stringToDouble(
rtl::OUString("INF1.23"),
'.', ',', &status, &end);
CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_OutOfRange, status);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), end);
CPPUNIT_ASSERT_EQUAL(rtl::math::isInf(res), true);
CPPUNIT_ASSERT_EQUAL(true, rtl::math::isInf(res));
res = rtl::math::stringToDouble(
rtl::OUString(".5"),
......
......@@ -128,7 +128,7 @@ public:
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"osl_getProcessInfo returned with failure",
osl_error, osl_Process_E_None
osl_Process_E_None, osl_error
);
printf("the exit code is %" SAL_PRIuUINT32 ".\n", pInfo->Code );
......
......@@ -46,10 +46,10 @@ void AttributesTest::test()
CPPUNIT_ASSERT( xAttributeList->hasAttribute(1) );
CPPUNIT_ASSERT( !xAttributeList->hasAttribute(3) );
CPPUNIT_ASSERT_EQUAL( xAttributeList->getOptionalValue(2), OUString("2") );
CPPUNIT_ASSERT_EQUAL( xAttributeList->getOptionalValue(3), OUString() );
CPPUNIT_ASSERT_EQUAL( OUString("2"), xAttributeList->getOptionalValue(2) );
CPPUNIT_ASSERT_EQUAL( OUString(), xAttributeList->getOptionalValue(3) );
CPPUNIT_ASSERT_EQUAL( xAttributeList->getValue(1), OUString("1") );
CPPUNIT_ASSERT_EQUAL( OUString("1"), xAttributeList->getValue(1) );
CPPUNIT_ASSERT_THROW( xAttributeList->getValue(3), xml::sax::SAXException );
xAttributeList->addUnknown("a", "a");
......
......@@ -243,7 +243,7 @@ void testContentImpl(ScDocument& rDoc, sal_Int32 nFormat ) //same code for ods,
ScAddress aAddress(7, 2, 0);
ScPostIt* pNote = rDoc.GetNote(aAddress);
CPPUNIT_ASSERT_MESSAGE("note not imported", pNote);
CPPUNIT_ASSERT_EQUAL_MESSAGE("note text not imported correctly", pNote->GetText(), OUString("Test"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("note text not imported correctly", OUString("Test"), pNote->GetText() );
}
//add additional checks here
......
......@@ -64,7 +64,7 @@ void testDataBar_Impl(const ScDocument& rDoc)
CPPUNIT_ASSERT_EQUAL(size_t(1), (*itr)->size());
const ScFormatEntry* pFormatEntry = (*itr)->GetEntry(0);
CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), ScFormatEntry::Type::Databar);
CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Databar, pFormatEntry->GetType());
const ScDataBarFormat* pDataBar = static_cast<const ScDataBarFormat*>(pFormatEntry);
CPPUNIT_ASSERT(pDataBar);
const ScDataBarFormatData* pDataBarData = pDataBar->GetDataBarData();
......@@ -101,7 +101,7 @@ void testColorScale2Entry_Impl(const ScDocument& rDoc)
CPPUNIT_ASSERT_EQUAL(size_t(1), (*itr)->size());
const ScFormatEntry* pFormatEntry = (*itr)->GetEntry(0);
CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), ScFormatEntry::Type::Colorscale);
CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Colorscale, pFormatEntry->GetType());
const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry);
CPPUNIT_ASSERT_EQUAL(size_t(2), pColFormat->size());
......@@ -140,7 +140,7 @@ void testColorScale3Entry_Impl(const ScDocument& rDoc)
CPPUNIT_ASSERT_EQUAL(size_t(1), (*itr)->size());
const ScFormatEntry* pFormatEntry = (*itr)->GetEntry(0);
CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), ScFormatEntry::Type::Colorscale);
CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Colorscale, pFormatEntry->GetType());
const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry);
CPPUNIT_ASSERT_EQUAL(size_t(3), pColFormat->size());
......
......@@ -115,7 +115,7 @@ void Test::testDeleteArea_4Ranges()
ScRangeList aList(ScRange(0,0,0,5,5,0));
aList.DeleteArea(2,2,0,3,3,0);
CPPUNIT_ASSERT_EQUAL(aList.size(), static_cast<size_t>(4));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), aList.size());
for(SCCOL nCol = 0; nCol <= 5; ++nCol)
{
for(SCROW nRow = 0; nRow <= 5; ++nRow)
......@@ -236,8 +236,8 @@ void Test::testDeleteArea_2Ranges()
aList.DeleteArea(4,4,0,6,7,0);
aList2.DeleteArea(4,4,0,6,7,0);
CPPUNIT_ASSERT_EQUAL(aList.size(), static_cast<size_t>(2));
CPPUNIT_ASSERT_EQUAL(aList2.size(), static_cast<size_t>(2));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aList.size());
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aList2.size());
for(SCCOL nCol = 0; nCol <= 5; ++nCol)
{
......
......@@ -698,13 +698,13 @@ void ScFiltersTest::testCachedFormulaResultsODS()
aIsErrorFormula.append(")");
OUString aFormula = aIsErrorFormula.makeStringAndClear();
rDoc.SetString(nCol, nRow + 2, 2, aFormula);
CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr(), rDoc.GetString(nCol, nRow +2, 2), OUString("TRUE"));
CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr(), OUString("TRUE"), rDoc.GetString(nCol, nRow +2, 2));
OUStringBuffer aIsTextFormula("=ISTEXT(");