aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/test/org/openintents
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-01-29 20:43:35 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2015-01-29 20:43:35 +0100
commitdccef45dc1646d623c01dcde7a28711b2ac815e4 (patch)
treee3b0cc6f01b9ec843bf90419b96d6e7c092d874e /src/main/test/org/openintents
parentc8766a788884d331c0b61eb74241abd65e9b90b9 (diff)
downloadopenpgp-api-dccef45dc1646d623c01dcde7a28711b2ac815e4.tar.gz
openpgp-api-dccef45dc1646d623c01dcde7a28711b2ac815e4.tar.bz2
openpgp-api-dccef45dc1646d623c01dcde7a28711b2ac815e4.zip
Change to gradle file structure, include changes by ligi
Diffstat (limited to 'src/main/test/org/openintents')
-rw-r--r--src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java b/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java
new file mode 100644
index 0000000..f115398
--- /dev/null
+++ b/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java
@@ -0,0 +1,50 @@
+package test.org.openintents.openpgp;
+
+import org.openintents.openpgp.util.OpenPgpUtils;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openintents.openpgp.util.OpenPgpUtils;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+@RunWith(AndroidJUnit4.class)
+public class OpenPgpUtilsTest {
+ @Test
+ public void splitCompleteUserIdShouldReturnAll3Components() throws Exception {
+ OpenPgpUtils.UserInfo info = OpenPgpUtils.splitUserId("Max Mustermann (this is a comment) <max@example.com>");
+ assertEquals("Max Mustermann", info.name);
+ assertEquals("this is a comment", info.comment);
+ assertEquals("max@example.com", info.email);
+ }
+
+ @Test
+ public void splitUserIdWithAllButCommentShouldReturnNameAndEmail() throws Exception {
+ OpenPgpUtils.UserInfo info = OpenPgpUtils.splitUserId("Max Mustermann <max@example.com>");
+ assertEquals("Max Mustermann", info.name);
+ assertNull(info.comment);
+ assertEquals("max@example.com", info.email);
+ }
+
+ @Test
+ public void splitUserIdWithAllButEmailShouldReturnNameAndComment() throws Exception {
+ OpenPgpUtils.UserInfo info = OpenPgpUtils.splitUserId("Max Mustermann (this is a comment)");
+ assertEquals(info.name, "Max Mustermann");
+ assertEquals(info.comment, "this is a comment");
+ assertNull(info.email);
+ }
+
+ @Test
+ public void splitUserIdWithOnlyNameShouldReturnNameOnly() throws Exception {
+ OpenPgpUtils.UserInfo info = OpenPgpUtils.splitUserId("Max Mustermann [this is a nothing]");
+ assertEquals("Max Mustermann", info.name);
+ assertNull(info.comment);
+ assertNull(info.email);
+ }
+} \ No newline at end of file