|
| 1 | +/* |
| 2 | + * Copyright 2026 Glavo |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.glavo.nbt.tag; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | + |
| 20 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 21 | +import static org.junit.jupiter.api.Assertions.assertSame; |
| 22 | + |
| 23 | +final class ValueTagTests { |
| 24 | + |
| 25 | + @Test |
| 26 | + void testGetType() { |
| 27 | + assertSame(TagType.BYTE, new ByteTag().getType()); |
| 28 | + assertSame(TagType.SHORT, new ShortTag().getType()); |
| 29 | + assertSame(TagType.INT, new IntTag().getType()); |
| 30 | + assertSame(TagType.LONG, new LongTag().getType()); |
| 31 | + assertSame(TagType.FLOAT, new FloatTag().getType()); |
| 32 | + assertSame(TagType.DOUBLE, new DoubleTag().getType()); |
| 33 | + assertSame(TagType.STRING, new StringTag().getType()); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + void testDefaultConstructor() { |
| 38 | + { |
| 39 | + var tag = new ByteTag(); |
| 40 | + assertEquals("", tag.getName()); |
| 41 | + assertEquals((byte) 0, tag.get()); |
| 42 | + assertEquals(0, tag.getUnsigned()); |
| 43 | + assertEquals(Byte.valueOf((byte) 0), tag.getValue()); |
| 44 | + assertEquals("0", tag.getAsString()); |
| 45 | + } |
| 46 | + |
| 47 | + { |
| 48 | + var tag = new ShortTag(); |
| 49 | + assertEquals("", tag.getName()); |
| 50 | + assertEquals((short) 0, tag.get()); |
| 51 | + assertEquals(0, tag.getUnsigned()); |
| 52 | + assertEquals(Short.valueOf((short) 0), tag.getValue()); |
| 53 | + assertEquals("0", tag.getAsString()); |
| 54 | + } |
| 55 | + |
| 56 | + { |
| 57 | + var tag = new IntTag(); |
| 58 | + assertEquals("", tag.getName()); |
| 59 | + assertEquals(0, tag.get()); |
| 60 | + assertEquals(0L, tag.getUnsigned()); |
| 61 | + assertEquals(Integer.valueOf(0), tag.getValue()); |
| 62 | + assertEquals("0", tag.getAsString()); |
| 63 | + } |
| 64 | + |
| 65 | + { |
| 66 | + var tag = new LongTag(); |
| 67 | + assertEquals("", tag.getName()); |
| 68 | + assertEquals(0L, tag.get()); |
| 69 | + assertEquals(Long.valueOf(0L), tag.getValue()); |
| 70 | + assertEquals("0", tag.getAsString()); |
| 71 | + } |
| 72 | + |
| 73 | + { |
| 74 | + var tag = new FloatTag(); |
| 75 | + assertEquals("", tag.getName()); |
| 76 | + assertEquals(0.0f, tag.get()); |
| 77 | + assertEquals(Float.valueOf(0.0f), tag.getValue()); |
| 78 | + assertEquals("0.0", tag.getAsString()); |
| 79 | + } |
| 80 | + |
| 81 | + { |
| 82 | + var tag = new DoubleTag(); |
| 83 | + assertEquals("", tag.getName()); |
| 84 | + assertEquals(0.0, tag.get()); |
| 85 | + assertEquals(Double.valueOf(0.0), tag.getValue()); |
| 86 | + assertEquals("0.0", tag.getAsString()); |
| 87 | + } |
| 88 | + |
| 89 | + { |
| 90 | + var tag = new StringTag(); |
| 91 | + assertEquals("", tag.getName()); |
| 92 | + assertEquals("", tag.get()); |
| 93 | + assertEquals("", tag.getValue()); |
| 94 | + assertEquals("", tag.getAsString()); |
| 95 | + } |
| 96 | + } |
| 97 | +} |
0 commit comments