From 58cdea1ee22ffff0166117a8625e80ed3404564d Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Mon, 23 Jul 2018 05:02:25 -0400 Subject: [PATCH] Added some unit tests --- .../com/rarchives/ripme/tst/UtilsTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/java/com/rarchives/ripme/tst/UtilsTest.java diff --git a/src/test/java/com/rarchives/ripme/tst/UtilsTest.java b/src/test/java/com/rarchives/ripme/tst/UtilsTest.java new file mode 100644 index 00000000..d0789b39 --- /dev/null +++ b/src/test/java/com/rarchives/ripme/tst/UtilsTest.java @@ -0,0 +1,34 @@ +package com.rarchives.ripme.tst; + +import junit.framework.TestCase; +import com.rarchives.ripme.utils.Utils; + +public class UtilsTest extends TestCase { + + public void testGetEXTFromMagic() { + assertEquals("jpeg", Utils.getEXTFromMagic(new byte[]{-1, -40, -1, -37, 0, 0, 0, 0})); + } + + public void testStripURLParameter() { + assertEquals("http://example.tld/image.ext", + Utils.stripURLParameter("http://example.tld/image.ext?param", "param")); + } + + public void testShortenPath() { + String path = "/test/test/test/test/test/test/test/test/"; + assertEquals("/test/test1", Utils.shortenPath("/test/test1")); + assertEquals("/test/test/t...st/test/test", Utils.shortenPath(path)); + } + + public void testBytesToHumanReadable() { + assertEquals("10.00iB", Utils.bytesToHumanReadable(10)); + assertEquals("1.00KiB", Utils.bytesToHumanReadable(1024)); + assertEquals("1.00MiB", Utils.bytesToHumanReadable(1024 * 1024)); + assertEquals("1.00GiB", Utils.bytesToHumanReadable(1024 * 1024 * 1024)); + } + + public void testGetListOfAlbumRippers() throws Exception{ + assert(!Utils.getListOfAlbumRippers().isEmpty()); + } + +}