Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3733659

Browse files
authored
Merge branch 'master' into fix-11-bit-can-id
2 parentse091080 +68d3e0d commit3733659

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

‎api/CanMsg.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* INCLUDE
1313
**************************************************************************************/
1414

15-
#include<stdint.h>
15+
#include<inttypes.h>
1616
#include<string.h>
1717

1818
#include"Print.h"
@@ -77,9 +77,9 @@ class CanMsg : public Printable
7777

7878
/* Print the header.*/
7979
if (isStandardId())
80-
len =snprintf(buf,sizeof(buf),"[%03X] (%d) :",getStandardId(), data_length);
80+
len =snprintf(buf,sizeof(buf),"[%03" PRIX32"] (%d) :",getStandardId(), data_length);
8181
else
82-
len =snprintf(buf,sizeof(buf),"[%08X] (%d) :",getExtendedId(), data_length);
82+
len =snprintf(buf,sizeof(buf),"[%08" PRIX32"] (%d) :",getExtendedId(), data_length);
8383
size_t n = p.write(buf, len);
8484

8585
/* Print the data.*/

‎api/RingBuffer.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void RingBufferN<N>::store_char( uint8_t c )
7777
{
7878
_aucBuffer[_iHead] = c ;
7979
_iHead =nextIndex(_iHead);
80-
_numElems++;
80+
_numElems = _numElems +1;
8181
}
8282
}
8383

@@ -97,7 +97,7 @@ int RingBufferN<N>::read_char()
9797

9898
uint8_t value = _aucBuffer[_iTail];
9999
_iTail =nextIndex(_iTail);
100-
_numElems--;
100+
_numElems = _numElems -1;
101101

102102
return value;
103103
}
@@ -138,4 +138,4 @@ bool RingBufferN<N>::isFull()
138138
}
139139

140140
#endif/* _RING_BUFFER_*/
141-
#endif/* __cplusplus*/
141+
#endif/* __cplusplus*/

‎api/String.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ void String::move(String &rhs)
234234
String & String::operator = (const String &rhs)
235235
{
236236
if (this == &rhs)return *this;
237-
237+
238238
if (rhs.buffer)copy(rhs.buffer, rhs.len);
239239
elseinvalidate();
240-
240+
241241
return *this;
242242
}
243243

@@ -253,7 +253,7 @@ String & String::operator = (const char *cstr)
253253
{
254254
if (cstr)copy(cstr,strlen(cstr));
255255
elseinvalidate();
256-
256+
257257
return *this;
258258
}
259259

@@ -484,7 +484,7 @@ bool String::equalsIgnoreCase( const String &s2 ) const
484484
constchar *p2 = s2.buffer;
485485
while (*p1) {
486486
if (tolower(*p1++) !=tolower(*p2++))returnfalse;
487-
}
487+
}
488488
returntrue;
489489
}
490490

@@ -515,7 +515,7 @@ char String::charAt(unsigned int loc) const
515515
returnoperator[](loc);
516516
}
517517

518-
voidString::setCharAt(unsignedint loc,char c)
518+
voidString::setCharAt(unsignedint loc,char c)
519519
{
520520
if (loc < len) buffer[loc] = c;
521521
}
@@ -652,9 +652,9 @@ void String::replace(const String& find, const String& replace)
652652
}
653653
}elseif (diff <0) {
654654
unsignedint size = len;// compute size needed for result
655+
diff =0 - diff;
655656
while ((foundAt =strstr(readFrom, find.buffer)) !=NULL) {
656657
readFrom = foundAt + find.len;
657-
diff =0 - diff;
658658
size -= diff;
659659
}
660660
if (size == len)return;

‎test/src/String/test_replace.cpp‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,24 @@ TEST_CASE ("Testing String::replace(String, String) substr 'find' smaller than '
6666
str.replace(arduino::String("ll"),arduino::String("111"));
6767
REQUIRE(str =="He111o Arduino!");
6868
}
69+
70+
TEST_CASE ("Testing String::replace(String, String) substr 'find' smaller than 'replace' multiple occurencies","[String-replace-08]")
71+
{
72+
arduino::Stringstr("Hello Arduino! Hello, Hello, Hello");
73+
str.replace(arduino::String("ll"),arduino::String("lll"));
74+
REQUIRE(str =="Helllo Arduino! Helllo, Helllo, Helllo");
75+
}
76+
77+
TEST_CASE ("Testing String::replace(String, String) substr 'find' same length as 'replace' multiple occurencies","[String-replace-09]")
78+
{
79+
arduino::Stringstr("Hello Arduino! Hello, Hello, Hello");
80+
str.replace(arduino::String("ll"),arduino::String("11"));
81+
REQUIRE(str =="He11o Arduino! He11o, He11o, He11o");
82+
}
83+
84+
TEST_CASE ("Testing String::replace(String, String) substr 'find' larger than 'replace' multiple occurencies","[String-replace-10]")
85+
{
86+
arduino::Stringstr("Helllo Arduino! Helllo, Helllo, Helllo");
87+
str.replace(arduino::String("lll"),arduino::String("ll"));
88+
REQUIRE(str =="Hello Arduino! Hello, Hello, Hello");
89+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp