Search in sources :

Example 1 with JSONSource

use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.

the class ClientMeasureBoxTest method testPacketByteBuf.

@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class, ParseIdentifier.class, ParseDyeColor.class, Boolean.class }, jsons = { "(1|2|0), (0|0|0), overworld, red, true", "(-1020|30|10), (-1000|100|20), end, blue, false", "(1|2|0), (0|256|0), overworld, red, true", "(1400|2|-6000), (1200|32|-5000), nether, red, true" })
void testPacketByteBuf(final BlockPos bp0, final BlockPos bp1, final Identifier dimension, final DyeColor color, final boolean finished) {
    final PacketByteBuf expectedBuf = new PacketByteBuf(Unpooled.buffer());
    expectedBuf.writeBlockPos(bp0);
    expectedBuf.writeBlockPos(bp1);
    expectedBuf.writeIdentifier(dimension);
    expectedBuf.writeInt(color.getId());
    expectedBuf.writeBoolean(finished);
    expectedBuf.writeInt(0);
    expectedBuf.writeInt(0);
    final ClientMeasureBox mb = ClientMeasureBox.fromPacketByteBuf(expectedBuf);
    final PacketByteBuf actualBuf = new PacketByteBuf(Unpooled.buffer());
    mb.writePacketBuf(actualBuf);
    expectedBuf.resetReaderIndex();
    assertThat(expectedBuf).isEqualTo(actualBuf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with JSONSource

use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.

the class ClientMeasureBoxTest method testIsCorner.

@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class }, jsons = { "(0|0|0), (10|10|10), (0|0|10), (0|10|0), (0|10|10), (10|0|0), (10|0|10), (10|10|0)", "(-30|5|25), (-90|2|50), (-30|5|50), (-30|2|25), (-30|2|50), (-90|5|25), (-90|5|50), (-90|2|25)" })
void testIsCorner(BlockPos bp0, BlockPos bp1, BlockPos bp2, BlockPos bp3, BlockPos bp4, BlockPos bp5, BlockPos bp6, BlockPos bp7) {
    try (MockedStatic<BlockMeterClient> client = getBMC()) {
        final ClientMeasureBox box = ClientMeasureBox.getBox(bp0, OVERWORLD_ID);
        box.setBlockEnd(bp1);
        assertThat(box.isCorner(bp0));
        assertThat(box.isCorner(bp1));
        assertThat(box.isCorner(bp2));
        assertThat(box.isCorner(bp3));
        assertThat(box.isCorner(bp4));
        assertThat(box.isCorner(bp5));
        assertThat(box.isCorner(bp6));
        assertThat(box.isCorner(bp7));
    }
}
Also used : ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with JSONSource

use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.

the class ClientMeasureBoxTest method testSetBlockEnd.

@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class }, jsons = { "(0|0|0), (0|0|0)", "(-10|0|10000), (-500|0|10200)" })
void testSetBlockEnd(final BlockPos bp0, final BlockPos bp1) {
    try (MockedStatic<BlockMeterClient> client = getBMC()) {
        final ClientMeasureBox box = ClientMeasureBox.getBox(bp0, OVERWORLD_ID);
        box.setBlockEnd(bp1);
        assertThat(box.getBlockStart()).isEqualTo(bp0);
        assertThat(box.getBlockEnd()).isEqualTo(bp1);
    }
}
Also used : ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with JSONSource

use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.

the class ClientMeasureBoxTest method testSetColor.

@ParameterizedTest
@JSONSource(classes = { ParseDyeColor.class }, jsons = { "red", "black", "green", "blue" })
void testSetColor(final DyeColor color) {
    try (MockedStatic<BlockMeterClient> client = getBMC()) {
        final ClientMeasureBox box = ClientMeasureBox.getBox(new BlockPos(0, 0, 0), OVERWORLD_ID);
        box.setColor(color);
        assertThat(box.getColor()).isEqualTo(color);
    }
}
Also used : ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) BlockPos(net.minecraft.util.math.BlockPos) ParseBlockPos(de.modprog.blockmeter.util.parser.ParseBlockPos) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with JSONSource

use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.

the class ClientMeasureBoxTest method testLoosenCorner.

@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class }, jsons = { "(0|1|2), (3|4|5), (0|4|2)" })
void testLoosenCorner(BlockPos bp0, BlockPos bp1, BlockPos newBp0) {
    try (MockedStatic<BlockMeterClient> client = getBMC()) {
        final ClientMeasureBox box = ClientMeasureBox.getBox(bp0, OVERWORLD_ID);
        box.setBlockEnd(bp1);
        box.setFinished();
        box.loosenCorner(newBp0);
        assertThat(box.isCorner(bp0)).isTrue();
        assertThat(box.isCorner(bp1)).isTrue();
        assertThat(box.getBlockEnd()).isEqualTo(newBp0);
        assertThat(box.isFinished()).isFalse();
    }
}
Also used : ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

JSONSource (de.modprog.blockmeter.util.JSONSource)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 ClientMeasureBox (win.baruna.blockmeter.measurebox.ClientMeasureBox)7 BlockMeterClient (win.baruna.blockmeter.BlockMeterClient)6 ParseBlockPos (de.modprog.blockmeter.util.parser.ParseBlockPos)2 PacketByteBuf (net.minecraft.network.PacketByteBuf)2 BlockPos (net.minecraft.util.math.BlockPos)2 ModConfig (win.baruna.blockmeter.ModConfig)1 MeasureBox (win.baruna.blockmeter.measurebox.MeasureBox)1