Renamed JsonArray::removeAt() into remove()

This commit is contained in:
Benoit Blanchon
2017-04-12 17:03:33 +02:00
parent 8c6f64c111
commit f2ef338cb8
6 changed files with 21 additions and 5 deletions

View File

@ -6,6 +6,7 @@ HEAD
* Added `JsonArray::remove(iterator)` (issue #479) * Added `JsonArray::remove(iterator)` (issue #479)
* Added `JsonObject::remove(iterator)` * Added `JsonObject::remove(iterator)`
* Renamed `JsonArray::removeAt(size_t)` into `remove(size_t)`
v5.8.4 v5.8.4
------ ------

View File

@ -89,6 +89,8 @@ class List {
protected: protected:
JsonBuffer *_buffer; JsonBuffer *_buffer;
private:
node_type *_firstNode; node_type *_firstNode;
}; };
} }

View File

@ -131,7 +131,7 @@ class JsonArray : public Internals::JsonPrintable<JsonArray>,
JsonObject &createNestedObject(); JsonObject &createNestedObject();
// Removes element at specified index. // Removes element at specified index.
void removeAt(size_t index) { void remove(size_t index) {
remove(begin() += index); remove(begin() += index);
} }
using Internals::List<JsonVariant>::remove; using Internals::List<JsonVariant>::remove;
@ -197,6 +197,13 @@ class JsonArray : public Internals::JsonPrintable<JsonArray>,
} }
} }
#if ARDUINOJSON_ENABLE_DEPRECATED
DEPRECATED("use remove() instead")
FORCE_INLINE void removeAt(size_t index) {
return remove(index);
}
#endif
private: private:
template <typename TValueRef> template <typename TValueRef>
bool set_impl(size_t index, TValueRef value) { bool set_impl(size_t index, TValueRef value) {

View File

@ -14,7 +14,7 @@ add_executable(JsonArrayTests
iterator.cpp iterator.cpp
prettyPrintTo.cpp prettyPrintTo.cpp
printTo.cpp printTo.cpp
removeAt.cpp remove.cpp
set.cpp set.cpp
subscript.cpp subscript.cpp
) )

View File

@ -23,7 +23,7 @@ class JsonArray_Remove_Tests : public ::testing::Test {
#define TEST_(name) TEST_F(JsonArray_Remove_Tests, name) #define TEST_(name) TEST_F(JsonArray_Remove_Tests, name)
TEST_(RemoveFirstByIndex) { TEST_(RemoveFirstByIndex) {
_array.removeAt(0); _array.remove(0);
EXPECT_EQ(2, _array.size()); EXPECT_EQ(2, _array.size());
EXPECT_STREQ("two", _array[0]); EXPECT_STREQ("two", _array[0]);
@ -31,7 +31,7 @@ TEST_(RemoveFirstByIndex) {
} }
TEST_(RemoveMiddleByIndex) { TEST_(RemoveMiddleByIndex) {
_array.removeAt(1); _array.remove(1);
EXPECT_EQ(2, _array.size()); EXPECT_EQ(2, _array.size());
EXPECT_STREQ("one", _array[0]); EXPECT_STREQ("one", _array[0]);
@ -39,7 +39,7 @@ TEST_(RemoveMiddleByIndex) {
} }
TEST_(RemoveLastByIndex) { TEST_(RemoveLastByIndex) {
_array.removeAt(2); _array.remove(2);
EXPECT_EQ(2, _array.size()); EXPECT_EQ(2, _array.size());
EXPECT_STREQ("one", _array[0]); EXPECT_STREQ("one", _array[0]);

View File

@ -34,3 +34,9 @@ TEST(Deprecated, asString) {
JsonVariant variant = "hello"; JsonVariant variant = "hello";
ASSERT_STREQ("hello", variant.asString()); ASSERT_STREQ("hello", variant.asString());
} }
TEST(Deprecated, removeAt) {
DynamicJsonBuffer jsonBuffer;
JsonArray& arr = jsonBuffer.createArray();
arr.removeAt(0);
}