1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.imaging.formats.bmp;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20 import static org.junit.jupiter.api.Assertions.assertThrows;
21
22 import java.io.File;
23 import java.io.IOException;
24
25 import org.apache.commons.imaging.ImageInfo;
26 import org.apache.commons.imaging.ImagingException;
27 import org.apache.commons.imaging.test.TestResources;
28 import org.junit.jupiter.api.Test;
29
30
31
32
33 public class BmpImageParserTest {
34
35
36
37
38
39
40
41 @Test
42 public void testImageForNegativeArraySizeException() throws ImagingException, IOException {
43 final File bmp = TestResources.resourceToFile("/images/bmp/IMAGING-279/negative_array_size_exception.bmp");
44 final BmpImageParser parser = new BmpImageParser();
45 assertThrows(IllegalArgumentException.class, () -> parser.getImageInfo(bmp, new BmpImagingParameters()));
46 }
47
48
49
50
51
52
53
54 @Test
55 public void testImageWidthRounding() throws ImagingException, IOException {
56 final File bmp = TestResources.resourceToFile("/images/bmp/IMAGING-264/test-72_6-dpi.bmp");
57 final BmpImageParser parser = new BmpImageParser();
58 final ImageInfo imageInfo = parser.getImageInfo(bmp, new BmpImagingParameters());
59 assertEquals(73, imageInfo.getPhysicalWidthDpi(), "Expected 72.6 resolution to be rounded to 73");
60 }
61 }