knowm / XChart

XChart is a light-weight Java library for plotting data.
http://knowm.org/open-source/xchart
Apache License 2.0
1.5k stars 396 forks source link

Bug: BitmapEncoder not accepting uppercase format of extension #852

Closed Prajun2010 closed 4 months ago

Prajun2010 commented 4 months ago

Describe the bug File extensions with uppercase, eg."image.PNG", are not supported by addFileExtension() method of BitmapEncoder class.

To Reproduce

public class BitmapEncoderTest {

    @Test
    public void testAddFileExtension() {
        String fileName1 = "image";
        String fileName2 = "image.png";
        String fileName3 = "image.PNG";

        Assert.assertEquals(BitmapEncoder.addFileExtension(fileName1, BitmapEncoder.BitmapFormat.PNG), "image.png");
        Assert.assertEquals(BitmapEncoder.addFileExtension(fileName2, BitmapEncoder.BitmapFormat.PNG), "image.png");
        Assert.assertEquals(BitmapEncoder.addFileExtension(fileName3, BitmapEncoder.BitmapFormat.PNG), "image.png");
    }
}

Screenshots image

Expected behavior The method should accept both lowercase and uppercase formats of a file extension. Eg: "PNG" == "png"

mccartney commented 4 months ago

Thanks for the report and the test case. It has definitely helped.