forked from libgdx/libgdx
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear list pointers of child before adding it to a JsonValue (libgdx#…
…7044) * Add test for removing and adding a json value * Clear list pointers of child before adding it to a JsonValue * Update CHANGES
- Loading branch information
1 parent
02202a3
commit f341273
Showing
3 changed files
with
37 additions
and
2 deletions.
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
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,32 @@ | ||
|
||
package com.badlogic.gdx.utils; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class JsonValueTest { | ||
|
||
@Test | ||
public void testAddingRemovedValue () { | ||
// Prepare two JSON objects | ||
JsonValue firstObject = new JsonValue(JsonValue.ValueType.object); | ||
JsonValue secondObject = new JsonValue(JsonValue.ValueType.object); | ||
|
||
firstObject.addChild("a", new JsonValue("A")); | ||
secondObject.addChild("b", new JsonValue("B")); | ||
secondObject.addChild("c", new JsonValue("C")); | ||
|
||
// Remove an item from one object and add it to the other | ||
JsonValue b = secondObject.remove("b"); | ||
firstObject.addChild(b); | ||
|
||
// Check if both objects have the expected children | ||
Assert.assertNotNull(firstObject.get("a")); | ||
Assert.assertNotNull(firstObject.get("b")); | ||
Assert.assertNull(firstObject.get("c")); | ||
|
||
Assert.assertNull(secondObject.get("a")); | ||
Assert.assertNull(secondObject.get("b")); | ||
Assert.assertNotNull(secondObject.get("c")); | ||
} | ||
} |