Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit 799120a

Browse files
author
Antti Yli-Tokola
committed
Fix unit test compilation
1 parent ba2d65d commit 799120a

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

test/mbed-client-mbed-tls/unittest/stub/m2mstring_stub.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ char* String::strdup(const char* s)
3636
String::String()
3737
: p( strdup("") )
3838
{
39-
_return_value = '\0';
4039
}
4140

4241
String::~String()
@@ -55,13 +54,11 @@ String::String(const String& s)
5554
size_ = s.size_;
5655
memcpy(p, s.p, size_ + 1);
5756
}
58-
_return_value = '\0';
5957
}
6058

6159
String::String(const char* s)
6260
: p(strdup(s))
6361
{
64-
_return_value = '\0';
6562
}
6663

6764
String& String::operator=(const char* s)
@@ -179,16 +176,6 @@ String String::substr(const size_type pos, size_type length) const
179176

180177

181178
// checked access, accessing the NUL at end is allowed
182-
char& String::at(const size_type i)
183-
{
184-
if ( i <= strlen(p) ) {
185-
_return_value = p[i];
186-
} else {
187-
_return_value = '\0';
188-
}
189-
return _return_value;
190-
}
191-
192179
char String::at(const size_type i) const
193180
{
194181
if ( i <= strlen(p) ) {
@@ -236,6 +223,26 @@ String& String::append( const char* str, size_type n) {
236223
return *this;
237224
}
238225

226+
String& String::append_raw( const char* str, size_type n) {
227+
if (str && n > 0) {
228+
size_t newlen = size_ + n;
229+
this->reserve( newlen );
230+
memmove(p+size_, str, n); // p and s.p MAY overlap
231+
p[newlen] = 0; // add NUL termination
232+
size_ = newlen;
233+
}
234+
return *this;
235+
}
236+
237+
void String::append_int(int param) {
238+
239+
// max len of "-9223372036854775808" plus zero termination
240+
char conv_buff[20+1];
241+
242+
int len = itoa_c(param, conv_buff);
243+
append_raw(conv_buff, len);
244+
}
245+
239246
int String::compare( size_type pos, size_type len, const String& str ) const {
240247
int r = -1;
241248
if (pos <= size_) {

0 commit comments

Comments
 (0)