From 09480d939013e0ebe9d8d89d57ae461d63c181d4 Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Wed, 2 Aug 2017 00:48:45 +0100 Subject: Ensure that we have a single `/` --- .../java/com/zeapo/pwdstore/DecryptTest.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'app/src/androidTest/java/com/zeapo') diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt b/app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt index 2bf1083e..6823f67a 100644 --- a/app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt +++ b/app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt @@ -56,12 +56,19 @@ class DecryptTest { @Test fun pathShouldDecompose() { - init() - - assertEquals("/category/sub.gpg", PgpActivity.getRelativePath(path, repoPath)) - assertEquals("/category/", PgpActivity.getParentPath(path, repoPath)) - assertEquals("sub", PgpActivity.getName(path, repoPath)) - assertEquals("sub", PgpActivity.getName(path, "$repoPath/")) + val pathOne = "/fake/path/cat1/n1.gpg".replace("//", "/") + val pathTwo = "/fake/path/n2.gpg".replace("//", "/") + + assertEquals("/cat1/n1.gpg", PgpActivity.getRelativePath(pathOne, "/fake/path")) + assertEquals("/cat1/", PgpActivity.getParentPath(pathOne, "/fake/path")) + assertEquals("n1", PgpActivity.getName(pathOne, "/fake/path")) + // test that even if we append a `/` it still works + assertEquals("n1", PgpActivity.getName(pathOne, "/fake/path/")) + + assertEquals("/n2.gpg", PgpActivity.getRelativePath(pathTwo, "/fake/path")) + assertEquals("/", PgpActivity.getParentPath(pathTwo, "/fake/path")) + assertEquals("n2", PgpActivity.getName(pathTwo, "/fake/path")) + assertEquals("n2", PgpActivity.getName(pathTwo, "/fake/path/")) } @Test -- cgit v1.2.3