Skip to content

Commit d4befd3

Browse files
committed
[T] ReflectionUtils: Split tests
1 parent acc003b commit d4befd3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/java/org/hydev/mcpm/client/injector/PluginLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import static org.hydev.mcpm.utils.ReflectionUtils.setPrivateField;
2222

2323
/**
24-
* TODO: Write a description for this class!
24+
* Implementation of plugin hot-loading/unloading
2525
*
2626
* @author Azalea (https://github.com/hykilpikonna)
2727
* @since 2022-09-27

src/test/java/org/hydev/mcpm/utils/ReflectionUtilsTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ void getPrivateField()
2929
{
3030
var a = new A();
3131
var f = ReflectionUtils.getPrivateField(a, "field", new TypeToken<List<String>>(){}).orElseThrow();
32-
assert f.get(0).equals("meow");
33-
assert f.get(1).equals("qwq");
32+
assert f.equals(Arrays.asList("meow", "qwq"));
33+
}
3434

35-
// The obtained field is a pointer
35+
@Test
36+
void getPrivateFieldMutation()
37+
{
38+
// Show that the obtained field is a pointer, and its contents can be mutated
39+
var a = new A();
40+
var f = ReflectionUtils.getPrivateField(a, "field", new TypeToken<List<String>>(){}).orElseThrow();
3641
f.set(1, "wolf");
42+
3743
var newF = ReflectionUtils.getPrivateField(a, "field", new TypeToken<List<String>>(){}).orElseThrow();
3844
assert newF.get(1).equals("wolf");
3945
}

0 commit comments

Comments
 (0)