Add pathInvalidClear

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-04-13 22:26:56 +02:00
parent 6c250de41c
commit 57832351ea
2 changed files with 10 additions and 1 deletions

View File

@ -125,7 +125,7 @@ final class TagHandlerImpl implements TagHandler {
// Remove entry
{
Entry<?>[] finalEntries = pathHandlers[length - 1].entries;
if (finalEntries.length >= tagIndex) finalEntries[tagIndex] = null;
if (finalEntries.length > tagIndex) finalEntries[tagIndex] = null;
}
// Clear empty parents
boolean empty = false;

View File

@ -152,6 +152,15 @@ public class TagPathTest {
assertNull(handler.getTag(tag));
}
@Test
public void pathInvalidClear() {
var handler = TagHandler.newHandler();
var tag1 = Tag.Integer("pathInvalidClear1").path("key");
var tag2 = Tag.Integer("pathInvalidClear2").path("key");
handler.setTag(tag1, 5);
handler.setTag(tag2, null);
}
@Test
public void chaining() {
var handler = TagHandler.newHandler();