mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Added tests for Flash strings (closes #1070)
This commit is contained in:
@@ -14,7 +14,7 @@ class FlashStringAdapter {
|
||||
if (!other && !_str) return 0;
|
||||
if (!_str) return -1;
|
||||
if (!other) return 1;
|
||||
return -strcmp_P(other, reinterpret_cast<const char*>(_str));
|
||||
return int8_t(-strcmp_P(other, reinterpret_cast<const char*>(_str)));
|
||||
}
|
||||
|
||||
bool equals(const char* expected) const {
|
||||
|
||||
@@ -15,7 +15,8 @@ class SizedFlashStringAdapter {
|
||||
if (!other && !_str) return 0;
|
||||
if (!_str) return -1;
|
||||
if (!other) return 1;
|
||||
return -strncmp_P(other, reinterpret_cast<const char*>(_str), _size);
|
||||
return int8_t(
|
||||
-strncmp_P(other, reinterpret_cast<const char*>(_str), _size));
|
||||
}
|
||||
|
||||
bool equals(const char* expected) const {
|
||||
@@ -29,7 +30,7 @@ class SizedFlashStringAdapter {
|
||||
char* save(MemoryPool* pool) const {
|
||||
if (!_str) return NULL;
|
||||
char* dup = pool->allocFrozenString(_size);
|
||||
if (dup) memcpy_P(dup, (const char*)_str, _size);
|
||||
if (dup) memcpy_P(dup, reinterpret_cast<const char*>(_str), _size);
|
||||
return dup;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user