/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "sal/config.h" #include #include #include #include #include "cppunitassertequals.hxx" #define TEST1 CPPUNIT_ASSERT(b1 == b2) #define TEST2(x) x void test( bool b1, bool b2, OUString const & s1, OUString const & s2, T t, void * p, std::nullptr_t n) { CppUnit::Asserter::failIf(b1,""); CPPUNIT_ASSERT(b1 && b2); // expected-error {{rather split into two CPPUNIT_ASSERT [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT((b1 && b2)); // expected-error {{rather split into two CPPUNIT_ASSERT [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(!(b1 || b2)); // expected-error {{rather split into two CPPUNIT_ASSERT [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(!(b1 && b2)); CPPUNIT_ASSERT(!!(b1 && b2)); // expected-error {{rather split into two CPPUNIT_ASSERT [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT_MESSAGE("", b1 && b2); // expected-error {{rather split into two CPPUNIT_ASSERT_MESSAGE [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(b1 == b2); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(b1 != b2); CPPUNIT_ASSERT((b1 == b2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(!(b1 != b2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator != call when the operator itself is the topic) [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(!(b1 == b2)); CPPUNIT_ASSERT(!!(b1 == b2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT_MESSAGE("", b1 == b2); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL_MESSAGE when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(s1 == s2); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const rtl::OUString' and 'const rtl::OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(s1 != s2); CPPUNIT_ASSERT((s1 == s2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const rtl::OUString' and 'const rtl::OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(!(s1 != s2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const rtl::OUString' and 'const rtl::OUString' (or rewrite as an explicit operator != call when the operator itself is the topic) [loplugin:cppunitassertequals]}} CPPUNIT_ASSERT(!(s1 == s2)); CPPUNIT_ASSERT(!!(s1 == s2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const rtl::OUString' and 'const rtl::OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} TEST1; // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} TEST2(CPPUNIT_ASSERT(b1 == b2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} TEST2(TEST1); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} // Useful when testing an equality iterator itself: CPPUNIT_ASSERT(operator ==(s1, s1)); CPPUNIT_ASSERT(t.operator ==(t)); // `P == nullptr` for P of pointer type is awkward to write with CPPUNIT_ASSERT_EQUAL, and the // actual pointer values that would be printed if CPPUNIT_ASSERT_EQUAL failed would likely not be // very meaningful, so let it use CPPUNIT_ASSERT (but stick to CPPUNIT_ASSERT_EQUAL for // consistency in the unlikely case that P is of type std::nullptr_t): CPPUNIT_ASSERT(p == nullptr); CPPUNIT_ASSERT(n == nullptr); // expected-error-re {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'std::nullptr_t'{{( \(aka 'nullptr_t'\))?}} and '{{(std::)?}}nullptr_t' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}} // There might even be good reasons(?) not to warn inside explicit casts: 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: */ istro/lhm/libreoffice-5-2+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-08-30Pass "verbose" flag into antStephan Bergmann
Change-Id: I76d7c8a41d64baae3591dd188a2d2e46f17622bb Reviewed-on: https://gerrit.libreoffice.org/41735 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-08-26Remove gcj support from build system.Thorsten Behrens
Change-Id: I79fe046ff8c932c5f6a9a5f70970168e42d23702 Reviewed-on: https://gerrit.libreoffice.org/28406 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2014-11-26there is no HI country code, I suspect it should be HT for HaitiCaolán McNamara
https://github.com/languagetool-org/languagetool/pull/219 Change-Id: I32e5caac17165a77d0803e782a285a9f32752742
2014-11-12Fix common typos. No automatic tools. Handmade…Andrea Gelmini
Change-Id: I1ab4e23b0539f8d39974787f226e57a21f96e959 Reviewed-on: https://gerrit.libreoffice.org/12164 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2013-11-18surely we don't want ANY string anymoreCaolán McNamara
presumably a simple blank string makes a whole lot more sense in these langtag days Change-Id: Ib50f7aed782f04d5d1c1f84617061ba2f66153bc
2013-11-18support en-IE as wellCaolán McNamara
Change-Id: Ibf92c0044cdbea8c85a7a73258d883bd28d619e9
2013-11-04fdo#70393: move languagetool to a subdir of externalKhaled Hosny
Change-Id: I402682f21d16c3069d5b6885bd75998bd2e16b3f Reviewed-on: https://gerrit.libreoffice.org/6544 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>