|
| 1 | +/* |
| 2 | + * WorldEdit, a Minecraft world manipulation toolkit |
| 3 | + * Copyright (C) sk89q <http://www.sk89q.com> |
| 4 | + * Copyright (C) WorldEdit team and contributors |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License |
| 17 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | + |
| 20 | +package com.fastasyncworldedit.core.math; |
| 21 | + |
| 22 | +import com.fastasyncworldedit.core.util.collection.BlockVector3Set; |
| 23 | +import com.sk89q.worldedit.math.BlockVector3; |
| 24 | +import org.junit.jupiter.api.Test; |
| 25 | + |
| 26 | +import java.util.List; |
| 27 | + |
| 28 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 29 | + |
| 30 | +class LocalBlockVectorSetTest { |
| 31 | + |
| 32 | + @Test |
| 33 | + void upgradesWhenBlockVectorIsOutsideLocalRange() { |
| 34 | + BlockVector3Set set = LocalBlockVectorSet.wrapped(); |
| 35 | + BlockVector3 position = BlockVector3.at(-38, -357, -20); |
| 36 | + |
| 37 | + assertTrue(set.add(position)); |
| 38 | + assertTrue(set.contains(position)); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + void retainsExistingVectorsWhenUpgraded() { |
| 43 | + BlockVector3Set set = LocalBlockVectorSet.wrapped(); |
| 44 | + BlockVector3 originalPosition = BlockVector3.at(-38, 128, -20); |
| 45 | + BlockVector3 positionOutsideLocalRange = BlockVector3.at(-38, -357, -20); |
| 46 | + |
| 47 | + assertTrue(set.add(originalPosition)); |
| 48 | + assertTrue(set.add(positionOutsideLocalRange)); |
| 49 | + assertTrue(set.contains(originalPosition)); |
| 50 | + assertTrue(set.contains(positionOutsideLocalRange)); |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + void upgradesWhenBulkAddingVectorsOutsideLocalRange() { |
| 55 | + BlockVector3Set set = LocalBlockVectorSet.wrapped(); |
| 56 | + BlockVector3 positionInsideLocalRange = BlockVector3.at(-38, 128, -20); |
| 57 | + BlockVector3 positionOutsideLocalRange = BlockVector3.at(-38, -357, -20); |
| 58 | + |
| 59 | + assertTrue(set.addAll(List.of(positionInsideLocalRange, positionOutsideLocalRange))); |
| 60 | + assertTrue(set.contains(positionInsideLocalRange)); |
| 61 | + assertTrue(set.contains(positionOutsideLocalRange)); |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments