use of net.minecraft.nbt.LongArrayNBT in project Mekanism by mekanism.
the class CCArgumentWrapperPropertyTest method testListIntArrayToLongArray.
@Test
@DisplayName("Test serializing and deserializing lists of lists that would create the inner ones as an int array plus long array")
void testListIntArrayToLongArray() {
qt().forAll(lists().of(onlyInts()).ofSizeBetween(1, 15), lists().of(onlyLongs()).ofSizeBetween(1, 15)).check((ints, longs) -> {
ListNBT nbt = fromArray(fromInts(ints), fromLongs(longs));
ListNBT expected = fromArray(new LongArrayNBT(ints.stream().mapToLong(Number::longValue).toArray()), getExpected(longs));
return expected.equals(CCArgumentWrapperTestHelper.wrapAndSanitize(nbt, null, false));
});
}
use of net.minecraft.nbt.LongArrayNBT in project Mekanism by mekanism.
the class CCArgumentWrapperPropertyTest method checkSameLongArray.
private boolean checkSameLongArray(List<Long> longs, @Nullable Class<? extends INBT> targetClass, boolean includeHints) {
LongArrayNBT nbt = new LongArrayNBT(longs);
Object sanitized = CCArgumentWrapperTestHelper.wrapAndSanitize(nbt, targetClass, includeHints);
return getExpected(longs).equals(sanitized);
}
use of net.minecraft.nbt.LongArrayNBT in project Mekanism by mekanism.
the class CCArgumentWrapperPropertyTest method testListShortListToLongArray.
@Test
@DisplayName("Test serializing and deserializing lists of lists that would create the inner ones as a short list plus long array")
void testListShortListToLongArray() {
qt().forAll(lists().of(onlyShorts()).ofSizeBetween(1, 15), lists().of(onlyLongs()).ofSizeBetween(1, 15)).check((shorts, longs) -> {
ListNBT nbt = fromArray(fromShorts(shorts), fromLongs(longs));
ListNBT expected = fromArray(new LongArrayNBT(shorts.stream().mapToLong(Number::longValue).toArray()), getExpected(longs));
return expected.equals(CCArgumentWrapperTestHelper.wrapAndSanitize(nbt, null, false));
});
}
use of net.minecraft.nbt.LongArrayNBT in project Mekanism by mekanism.
the class CCArgumentWrapperTest method testInvalidListCompoundLongArray.
@Test
@DisplayName("Test making sure we fail to create a list out of invalid elements (non empty compound + long array)")
void testInvalidListCompoundLongArray() {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("key", "value");
assertMismatchedList(nbt, new LongArrayNBT(Collections.singletonList(Long.MAX_VALUE)));
}
use of net.minecraft.nbt.LongArrayNBT in project Mekanism by mekanism.
the class CCArgumentWrapperPropertyTest method testListLongArrayPlusEmpty.
@Test
@DisplayName("Test serializing and deserializing lists of lists that would create the inner ones as long arrays plus an empty list")
void testListLongArrayPlusEmpty() {
qt().forAll(lists().of(onlyLongs()).ofSizeBetween(1, 15)).check(longs -> {
ListNBT nbt = fromArray(fromLongs(longs), new ListNBT());
ListNBT expected = fromArray(getExpected(longs), new LongArrayNBT(new long[0]));
return expected.equals(CCArgumentWrapperTestHelper.wrapAndSanitize(nbt, null, false));
});
}
Aggregations