diff options
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestSignature.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestSignature.java | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/test/java/cuchaz/enigma/TestSignature.java b/src/test/java/cuchaz/enigma/TestSignature.java index 8537adf..534b43a 100644 --- a/src/test/java/cuchaz/enigma/TestSignature.java +++ b/src/test/java/cuchaz/enigma/TestSignature.java | |||
| @@ -4,31 +4,33 @@ | |||
| 4 | * are made available under the terms of the GNU Lesser General Public | 4 | * are made available under the terms of the GNU Lesser General Public |
| 5 | * License v3.0 which accompanies this distribution, and is available at | 5 | * License v3.0 which accompanies this distribution, and is available at |
| 6 | * http://www.gnu.org/licenses/lgpl.html | 6 | * http://www.gnu.org/licenses/lgpl.html |
| 7 | * | 7 | * |
| 8 | * Contributors: | 8 | * Contributors: |
| 9 | * Jeff Martin - initial API and implementation | 9 | * Jeff Martin - initial API and implementation |
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma; | ||
| 12 | |||
| 13 | import static org.hamcrest.MatcherAssert.*; | ||
| 14 | import static org.hamcrest.Matchers.*; | ||
| 15 | 11 | ||
| 16 | import org.junit.Test; | 12 | package cuchaz.enigma; |
| 17 | 13 | ||
| 18 | import cuchaz.enigma.mapping.ClassNameReplacer; | 14 | import cuchaz.enigma.mapping.ClassNameReplacer; |
| 19 | import cuchaz.enigma.mapping.Signature; | 15 | import cuchaz.enigma.mapping.Signature; |
| 20 | import cuchaz.enigma.mapping.Type; | 16 | import cuchaz.enigma.mapping.Type; |
| 17 | import org.junit.Test; | ||
| 21 | 18 | ||
| 19 | import static org.hamcrest.MatcherAssert.assertThat; | ||
| 20 | import static org.hamcrest.Matchers.contains; | ||
| 21 | import static org.hamcrest.Matchers.empty; | ||
| 22 | import static org.hamcrest.Matchers.is; | ||
| 23 | import static org.hamcrest.Matchers.not; | ||
| 22 | 24 | ||
| 23 | public class TestSignature { | 25 | public class TestSignature { |
| 24 | 26 | ||
| 25 | @Test | 27 | @Test |
| 26 | public void easiest() { | 28 | public void easiest() { |
| 27 | final Signature sig = new Signature("()V"); | 29 | final Signature sig = new Signature("()V"); |
| 28 | assertThat(sig.getArgumentTypes(), is(empty())); | 30 | assertThat(sig.getArgumentTypes(), is(empty())); |
| 29 | assertThat(sig.getReturnType(), is(new Type("V"))); | 31 | assertThat(sig.getReturnType(), is(new Type("V"))); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | @Test | 34 | @Test |
| 33 | public void primitives() { | 35 | public void primitives() { |
| 34 | { | 36 | { |
| @@ -56,7 +58,7 @@ public class TestSignature { | |||
| 56 | assertThat(sig.getReturnType(), is(new Type("Z"))); | 58 | assertThat(sig.getReturnType(), is(new Type("Z"))); |
| 57 | } | 59 | } |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | @Test | 62 | @Test |
| 61 | public void classes() { | 63 | public void classes() { |
| 62 | { | 64 | { |
| @@ -82,7 +84,7 @@ public class TestSignature { | |||
| 82 | assertThat(sig.getReturnType(), is(new Type("LBar;"))); | 84 | assertThat(sig.getReturnType(), is(new Type("LBar;"))); |
| 83 | } | 85 | } |
| 84 | } | 86 | } |
| 85 | 87 | ||
| 86 | @Test | 88 | @Test |
| 87 | public void arrays() { | 89 | public void arrays() { |
| 88 | { | 90 | { |
| @@ -109,7 +111,7 @@ public class TestSignature { | |||
| 109 | assertThat(sig.getReturnType(), is(new Type("[D"))); | 111 | assertThat(sig.getReturnType(), is(new Type("[D"))); |
| 110 | } | 112 | } |
| 111 | } | 113 | } |
| 112 | 114 | ||
| 113 | @Test | 115 | @Test |
| 114 | public void mixed() { | 116 | public void mixed() { |
| 115 | { | 117 | { |
| @@ -131,7 +133,7 @@ public class TestSignature { | |||
| 131 | assertThat(sig.getReturnType(), is(new Type("[LFoo;"))); | 133 | assertThat(sig.getReturnType(), is(new Type("[LFoo;"))); |
| 132 | } | 134 | } |
| 133 | } | 135 | } |
| 134 | 136 | ||
| 135 | @Test | 137 | @Test |
| 136 | public void replaceClasses() { | 138 | public void replaceClasses() { |
| 137 | { | 139 | { |
| @@ -195,7 +197,7 @@ public class TestSignature { | |||
| 195 | assertThat(sig.getReturnType(), is(new Type("LCow;"))); | 197 | assertThat(sig.getReturnType(), is(new Type("LCow;"))); |
| 196 | } | 198 | } |
| 197 | } | 199 | } |
| 198 | 200 | ||
| 199 | @Test | 201 | @Test |
| 200 | public void replaceArrayClasses() { | 202 | public void replaceArrayClasses() { |
| 201 | { | 203 | { |
| @@ -217,13 +219,13 @@ public class TestSignature { | |||
| 217 | assertThat(sig.getReturnType(), is(new Type("[[[LBeer;"))); | 219 | assertThat(sig.getReturnType(), is(new Type("[[[LBeer;"))); |
| 218 | } | 220 | } |
| 219 | } | 221 | } |
| 220 | 222 | ||
| 221 | @Test | 223 | @Test |
| 222 | public void equals() { | 224 | public void equals() { |
| 223 | 225 | ||
| 224 | // base | 226 | // base |
| 225 | assertThat(new Signature("()V"), is(new Signature("()V"))); | 227 | assertThat(new Signature("()V"), is(new Signature("()V"))); |
| 226 | 228 | ||
| 227 | // arguments | 229 | // arguments |
| 228 | assertThat(new Signature("(I)V"), is(new Signature("(I)V"))); | 230 | assertThat(new Signature("(I)V"), is(new Signature("(I)V"))); |
| 229 | assertThat(new Signature("(ZIZ)V"), is(new Signature("(ZIZ)V"))); | 231 | assertThat(new Signature("(ZIZ)V"), is(new Signature("(ZIZ)V"))); |
| @@ -238,7 +240,7 @@ public class TestSignature { | |||
| 238 | assertThat(new Signature("([[Z)V"), is(not(new Signature("([[LFoo;)V")))); | 240 | assertThat(new Signature("([[Z)V"), is(not(new Signature("([[LFoo;)V")))); |
| 239 | assertThat(new Signature("(LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V")))); | 241 | assertThat(new Signature("(LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V")))); |
| 240 | assertThat(new Signature("([LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V")))); | 242 | assertThat(new Signature("([LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V")))); |
| 241 | 243 | ||
| 242 | // return type | 244 | // return type |
| 243 | assertThat(new Signature("()I"), is(new Signature("()I"))); | 245 | assertThat(new Signature("()I"), is(new Signature("()I"))); |
| 244 | assertThat(new Signature("()Z"), is(new Signature("()Z"))); | 246 | assertThat(new Signature("()Z"), is(new Signature("()Z"))); |
| @@ -246,7 +248,7 @@ public class TestSignature { | |||
| 246 | assertThat(new Signature("()[[[Z"), is(new Signature("()[[[Z"))); | 248 | assertThat(new Signature("()[[[Z"), is(new Signature("()[[[Z"))); |
| 247 | assertThat(new Signature("()LFoo;"), is(new Signature("()LFoo;"))); | 249 | assertThat(new Signature("()LFoo;"), is(new Signature("()LFoo;"))); |
| 248 | assertThat(new Signature("()[LFoo;"), is(new Signature("()[LFoo;"))); | 250 | assertThat(new Signature("()[LFoo;"), is(new Signature("()[LFoo;"))); |
| 249 | 251 | ||
| 250 | assertThat(new Signature("()I"), is(not(new Signature("()Z")))); | 252 | assertThat(new Signature("()I"), is(not(new Signature("()Z")))); |
| 251 | assertThat(new Signature("()Z"), is(not(new Signature("()I")))); | 253 | assertThat(new Signature("()Z"), is(not(new Signature("()I")))); |
| 252 | assertThat(new Signature("()[D"), is(not(new Signature("()[J")))); | 254 | assertThat(new Signature("()[D"), is(not(new Signature("()[J")))); |
| @@ -254,7 +256,7 @@ public class TestSignature { | |||
| 254 | assertThat(new Signature("()LFoo;"), is(not(new Signature("()LBar;")))); | 256 | assertThat(new Signature("()LFoo;"), is(not(new Signature("()LBar;")))); |
| 255 | assertThat(new Signature("()[LFoo;"), is(not(new Signature("()[LBar;")))); | 257 | assertThat(new Signature("()[LFoo;"), is(not(new Signature("()[LBar;")))); |
| 256 | } | 258 | } |
| 257 | 259 | ||
| 258 | @Test | 260 | @Test |
| 259 | public void testToString() { | 261 | public void testToString() { |
| 260 | assertThat(new Signature("()V").toString(), is("()V")); | 262 | assertThat(new Signature("()V").toString(), is("()V")); |