This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Method to remove tag inside NBTCompound and NBTList
+ Method to find index or remove tag inside NBTList
- Loading branch information
1 parent
126f55a
commit 56ed95a
Showing
5 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ java { | |
} | ||
|
||
group 'org.jglrxavpok.nbt' | ||
version '1.1.7' | ||
version '1.1.8' | ||
|
||
repositories { | ||
mavenCentral() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package nbt; | ||
|
||
import org.jglrxavpok.hephaistos.nbt.NBT; | ||
import org.jglrxavpok.hephaistos.nbt.NBTList; | ||
import org.jglrxavpok.hephaistos.nbt.NBTString; | ||
import org.jglrxavpok.hephaistos.nbt.NBTTypes; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class NBTListMethods { | ||
|
||
private NBTList<NBTString> list; | ||
|
||
@Before | ||
public void init() { | ||
list = new NBTList<>(NBTTypes.TAG_String); | ||
} | ||
|
||
@Test | ||
public void indexOf() { | ||
list.add(new NBTString("Some value0")); | ||
list.add(new NBTString("Some value1")); | ||
list.add(new NBTString("Some value2")); | ||
|
||
for (int i = 0; i < list.getLength(); i++) { | ||
NBTString valueAtI = list.get(i); | ||
assertEquals(i, list.indexOf(valueAtI)); | ||
} | ||
|
||
// indexOf uses equals | ||
assertEquals(0, list.indexOf(new NBTString("Some value0"))); | ||
assertEquals(1, list.indexOf(new NBTString("Some value1"))); | ||
assertEquals(2, list.indexOf(new NBTString("Some value2"))); | ||
|
||
list.removeAt(0); | ||
assertEquals(1, list.indexOf(new NBTString("Some value2"))); | ||
} | ||
|
||
@Test | ||
public void removeAt() { | ||
list.add(new NBTString("Some value0")); | ||
list.add(new NBTString("Some value1")); | ||
list.add(new NBTString("Some value2")); | ||
|
||
list.removeAt(0); | ||
assertEquals(2, list.getLength()); | ||
assertEquals("Some value2", list.get(1).getValue()); | ||
} | ||
|
||
@Test | ||
public void remove() { | ||
list.add(new NBTString("Some value0")); | ||
list.add(new NBTString("Some value1")); | ||
list.add(new NBTString("Some value2")); | ||
|
||
list.remove(new NBTString("Some value0")); | ||
assertEquals(2, list.getLength()); | ||
assertEquals("Some value2", list.get(1).getValue()); | ||
} | ||
|
||
@After | ||
public void clean() { | ||
list.clear(); | ||
list = null; | ||
} | ||
|
||
} |