Branch libreoffice-24-8-3
[LibreOffice.git] / external / cppunit / 0001-cid-1546460-COPY_INSTEAD_OF_MOVE.patch.1
blob742dce907bcc52b9c30c9b7a0628d29d2cff6b57
1 From ae5acc79d5f6e9b6f64cc550d858f41884362025 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolan.mcnamara@collabora.com>
3 Date: Sat, 30 Dec 2023 20:08:01 +0000
4 Subject: [PATCH] cid#1546460 COPY_INSTEAD_OF_MOVE
6 ---
7  src/cppunit/TestFactoryRegistry.cpp | 2 +-
8  1 file changed, 1 insertion(+), 1 deletion(-)
10 diff --git a/src/cppunit/TestFactoryRegistry.cpp b/src/cppunit/TestFactoryRegistry.cpp
11 index 3b68d58..7b38a34 100644
12 --- a/src/cppunit/TestFactoryRegistry.cpp
13 +++ b/src/cppunit/TestFactoryRegistry.cpp
14 @@ -85,7 +85,7 @@ public:
16  TestFactoryRegistry::TestFactoryRegistry( std::string name ) :
17      m_factories(),
18 -    m_name( name )
19 +    m_name(std::move(name))
20  {
21  }
23 diff --git a/src/cppunit/XmlElement.cpp b/src/cppunit/XmlElement.cpp
24 index 585c3da..be02385 100644
25 --- a/src/cppunit/XmlElement.cpp
26 +++ b/src/cppunit/XmlElement.cpp
27 @@ -8,8 +8,8 @@ CPPUNIT_NS_BEGIN
28    
29  XmlElement::XmlElement( std::string elementName,
30                          std::string content ) 
31 -  : m_name( elementName )
32 -  , m_content( content )
33 +  : m_name(std::move(elementName))
34 +  , m_content(std::move(content))
35    , m_attributes()
36    , m_elements()
37  {
38 @@ -18,7 +18,7 @@ XmlElement::XmlElement( std::string elementName,
39      
40  XmlElement::XmlElement( std::string elementName,
41                          int numericContent )
42 -  : m_name( elementName )
43 +  : m_name(std::move(elementName))
44    , m_content()
45    , m_attributes()
46    , m_elements()
47 @@ -74,15 +74,15 @@ XmlElement::setContent( int numericContent )
50  void 
51 -XmlElement::addAttribute( std::string attributeName,
52 -                          std::string value  )
53 +XmlElement::addAttribute( const std::string& attributeName,
54 +                          const std::string& value  )
55  {
56    m_attributes.push_back( Attribute( attributeName, value ) );
57  }
60  void 
61 -XmlElement::addAttribute( std::string attributeName,
62 +XmlElement::addAttribute( const std::string& attributeName,
63                            int numericValue )
64  {
65    addAttribute( attributeName, StringTools::toString( numericValue ) );
66 @@ -194,7 +194,7 @@ XmlElement::attributesAsString() const
69  std::string 
70 -XmlElement::escape( std::string value ) const
71 +XmlElement::escape( const std::string& value ) const
72  {
73    std::string escaped;
74    for ( unsigned int index =0; index < value.length(); ++index )
75 diff --git a/include/cppunit/tools/XmlElement.h b/include/cppunit/tools/XmlElement.h
76 index 3478a35..d033aa2 100644
77 --- a/include/cppunit/tools/XmlElement.h
78 +++ b/include/cppunit/tools/XmlElement.h
79 @@ -79,14 +79,14 @@ public:
80     * \param attributeName Name of the attribute. Must not be an empty.
81     * \param value Value of the attribute.
82     */
83 -  void addAttribute( std::string attributeName,
84 -                     std::string value );
85 +  void addAttribute( const std::string& attributeName,
86 +                     const std::string& value );
88    /*! \brief Adds an attribute with the specified numeric value.
89     * \param attributeName Name of the attribute. Must not be empty.
90     * \param numericValue Numeric value of the attribute.
91     */
92 -  void addAttribute( std::string attributeName,
93 +  void addAttribute( const std::string& attributeName,
94                       int numericValue );
96    /*! \brief Adds a child element to the element.
97 @@ -125,7 +125,7 @@ private:
98    typedef std::pair<std::string,std::string> Attribute;
100    std::string attributesAsString() const;
101 -  std::string escape( std::string value ) const;
102 +  std::string escape( const std::string& value ) const;
104  private:
105    std::string m_name;
106 diff --git a/include/cppunit/Asserter.h b/include/cppunit/Asserter.h
107 index ca65593..2010739 100644
108 --- a/include/cppunit/Asserter.h
109 +++ b/include/cppunit/Asserter.h
110 @@ -159,11 +159,11 @@
111     *                          what are the differences between the expected and actual value.
112     * \param shortDescription Short description for the failure message.
113     */
114 -  [[noreturn]] static void CPPUNIT_API failNotEqual( std::string expected, 
115 -                                        std::string actual, 
116 +  [[noreturn]] static void CPPUNIT_API failNotEqual( const std::string& expected, 
117 +                                        const std::string& actual, 
118                                          const SourceLine &sourceLine,
119                                          const AdditionalMessage &additionalMessage = AdditionalMessage(),
120 -                                        std::string shortDescription = "equality assertion failed" );
121 +                                        const std::string& shortDescription = "equality assertion failed" );
123    /*! \brief Throws an Exception with the specified message and location.
124     * \param expected Text describing the expected value.
125 @@ -231,11 +231,11 @@
126     * \param shortDescription Short description for the failure message.
127     */
128    static void CPPUNIT_API failNotEqualIf( bool shouldFail,
129 -                                          std::string expected, 
130 -                                          std::string actual, 
131 +                                          const std::string& expected, 
132 +                                          const std::string& actual, 
133                                            const SourceLine &sourceLine,
134                                            const AdditionalMessage &additionalMessage = AdditionalMessage(),
135 -                                          std::string shortDescription = "equality assertion failed" );
136 +                                          const std::string& shortDescription = "equality assertion failed" );
138  };
140 diff --git a/src/cppunit/Asserter.cpp b/src/cppunit/Asserter.cpp
141 index 52f8625..fe2097e 100644
142 --- a/src/cppunit/Asserter.cpp
143 +++ b/src/cppunit/Asserter.cpp
144 @@ -110,11 +110,11 @@
147  void 
148 -Asserter::failNotEqual( std::string expected, 
149 -                        std::string actual, 
150 +Asserter::failNotEqual( const std::string& expected, 
151 +                        const std::string& actual, 
152                          const SourceLine &sourceLine,
153                          const AdditionalMessage &additionalMessage,
154 -                        std::string shortDescription )
155 +                        const std::string& shortDescription )
157    fail( makeMessage( makeExpectedEqual(expected),
158                       makeActual(actual),
159 @@ -182,11 +182,11 @@
161  void 
162  Asserter::failNotEqualIf( bool shouldFail,
163 -                          std::string expected, 
164 -                          std::string actual, 
165 +                          const std::string& expected, 
166 +                          const std::string& actual, 
167                            const SourceLine &sourceLine,
168                            const AdditionalMessage &additionalMessage,
169 -                          std::string shortDescription )
170 +                          const std::string& shortDescription )
172    if ( shouldFail )
173      failNotEqual( expected, actual, sourceLine, additionalMessage, shortDescription );
174 -- 
175 2.43.0