Skip to content

Commit 7249050

Browse files
committed
Adding unit test for ADT/MCLY-subchunk
1 parent ad9fbc0 commit 7249050

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (C) 2019 Warkdev
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package eu.jangos.extractor.file.adt.chunk;
18+
19+
import eu.jangos.extractor.file.adt.chunk.MCLY;
20+
import eu.jangos.test.utils.ByteBufferUtils;
21+
import java.io.IOException;
22+
import java.nio.BufferUnderflowException;
23+
import java.nio.ByteBuffer;
24+
import org.junit.jupiter.api.Test;
25+
import static org.junit.jupiter.api.Assertions.*;
26+
27+
/**
28+
*
29+
* @author Warkdev
30+
*/
31+
public class MCLYTest {
32+
33+
/**
34+
* Test of read method, of class MCLY.
35+
*/
36+
@Test
37+
public void testRead() throws IOException {
38+
System.out.println("read");
39+
ByteBuffer in = ByteBufferUtils.getByteBuffer("legit/adt/MCLY/mcly001");
40+
MCLY instance = new MCLY();
41+
instance.read(in);
42+
assertEquals(18, instance.getTextureId());
43+
assertEquals(38, instance.getFlags());
44+
assertEquals(0, instance.getOffsetinMCAL());
45+
assertEquals(0, instance.getEffectId());
46+
}
47+
48+
@Test
49+
public void testReadWrongMCIN() throws IOException {
50+
MCIN instance = new MCIN();
51+
ByteBuffer in = ByteBufferUtils.getByteBuffer("legit/adt/MCLY/mcly002");
52+
assertThrows(BufferUnderflowException.class, () -> {
53+
instance.read(in);
54+
});
55+
}
56+
}
16 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)