Search in sources :

Example 1 with LongArrayNBT

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));
    });
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) LongArrayNBT(net.minecraft.nbt.LongArrayNBT) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with LongArrayNBT

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);
}
Also used : LongArrayNBT(net.minecraft.nbt.LongArrayNBT)

Example 3 with LongArrayNBT

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));
    });
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) LongArrayNBT(net.minecraft.nbt.LongArrayNBT) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with LongArrayNBT

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)));
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) LongArrayNBT(net.minecraft.nbt.LongArrayNBT) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with LongArrayNBT

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));
    });
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) LongArrayNBT(net.minecraft.nbt.LongArrayNBT) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

LongArrayNBT (net.minecraft.nbt.LongArrayNBT)9 DisplayName (org.junit.jupiter.api.DisplayName)7 Test (org.junit.jupiter.api.Test)7 ListNBT (net.minecraft.nbt.ListNBT)6 CompoundNBT (net.minecraft.nbt.CompoundNBT)2 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 ByteArrayNBT (net.minecraft.nbt.ByteArrayNBT)1 ByteNBT (net.minecraft.nbt.ByteNBT)1 CollectionNBT (net.minecraft.nbt.CollectionNBT)1 DoubleNBT (net.minecraft.nbt.DoubleNBT)1 FloatNBT (net.minecraft.nbt.FloatNBT)1 INBT (net.minecraft.nbt.INBT)1 IntArrayNBT (net.minecraft.nbt.IntArrayNBT)1 IntNBT (net.minecraft.nbt.IntNBT)1 LongNBT (net.minecraft.nbt.LongNBT)1 NumberNBT (net.minecraft.nbt.NumberNBT)1