diff options
Diffstat (limited to 'platform/platform-tests/testSrc/com/intellij/patterns/StandardPatternsTest.java')
-rw-r--r-- | platform/platform-tests/testSrc/com/intellij/patterns/StandardPatternsTest.java | 76 |
1 files changed, 32 insertions, 44 deletions
diff --git a/platform/platform-tests/testSrc/com/intellij/patterns/StandardPatternsTest.java b/platform/platform-tests/testSrc/com/intellij/patterns/StandardPatternsTest.java index 1e05add24302..1db3f319b250 100644 --- a/platform/platform-tests/testSrc/com/intellij/patterns/StandardPatternsTest.java +++ b/platform/platform-tests/testSrc/com/intellij/patterns/StandardPatternsTest.java @@ -1,11 +1,23 @@ /* - * Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved. + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.intellij.patterns; import com.intellij.openapi.util.Key; -import com.intellij.testFramework.UsefulTestCase; import com.intellij.util.ProcessingContext; +import junit.framework.TestCase; import java.util.Arrays; @@ -14,37 +26,15 @@ import static com.intellij.patterns.StandardPatterns.*; /** * @author peter */ -public class StandardPatternsTest extends UsefulTestCase { +public class StandardPatternsTest extends TestCase { - public void testNull() throws Throwable { + public void testNull() { assertTrue(object().isNull().accepts(null)); assertFalse(object().isNull().accepts("")); assertFalse(string().isNull().accepts("")); assertTrue(string().isNull().accepts(null)); } - public void testString() throws Throwable { - final ElementPattern pattern = string(); - assertFalse(string().accepts(new Object())); - assertTrue(pattern.accepts("")); - } - - public void testStartsWith() throws Throwable { - final ElementPattern pattern = string().startsWith("abc"); - assertFalse(pattern.accepts("")); - assertTrue(pattern.accepts("abcd")); - assertTrue(pattern.accepts("abc")); - - assertFalse(string().startsWith("abc").accepts(new Object())); - } - - public void testEndsWith() throws Throwable { - final ElementPattern pattern = string().endsWith("abc"); - assertFalse(pattern.accepts("")); - assertFalse(pattern.accepts("abcd")); - assertTrue(pattern.accepts("abc")); - } - private static void checkPrefixSuffix(final ElementPattern pattern) { assertFalse(pattern.accepts("")); assertFalse(pattern.accepts("abcd")); @@ -53,23 +43,23 @@ public class StandardPatternsTest extends UsefulTestCase { assertFalse(pattern.accepts("abcdab")); } - public void testPrefixSuffix() throws Throwable { + public void testPrefixSuffix() { checkPrefixSuffix(string().endsWith("abc").startsWith("abc")); } - public void testAnd1() throws Throwable { + public void testAnd1() { checkPrefixSuffix(and(string().endsWith("abc"), string().startsWith("abc"))); } - public void testAnd2() throws Throwable { + public void testAnd2() { checkPrefixSuffix(string().endsWith("abc").and(string().startsWith("abc"))); } - public void testOr1() throws Throwable { + public void testOr1() { checkOr(or(string().endsWith("abc"), string().startsWith("abc"))); } - public void testNot1() throws Throwable { + public void testNot1() { final ElementPattern pattern = not(or(string().endsWith("abc"), string().startsWith("abc"))); assertTrue(pattern.accepts("")); assertTrue(pattern.accepts("xxx")); @@ -90,7 +80,7 @@ public class StandardPatternsTest extends UsefulTestCase { assertTrue(filterFactory.accepts("abcdab")); } - public void testEquals() throws Throwable { + public void testEquals() { final Object foo = new Object(); final Object bar = new Object(); ElementPattern objectPattern = object().equalTo(foo); @@ -103,15 +93,14 @@ public class StandardPatternsTest extends UsefulTestCase { } - - public void testAll() throws Throwable { + public void testAll() { ElementPattern pattern = collection(String.class).all(string().startsWith("abc")); assertTrue(pattern.accepts(Arrays.asList("abc"))); assertTrue(pattern.accepts(Arrays.asList("abc", "abcd"))); assertFalse(pattern.accepts(Arrays.asList("abc", "bcd"))); } - public void testAtLeastOne() throws Throwable { + public void testAtLeastOne() { ElementPattern pattern = collection(String.class).atLeastOne(string().startsWith("abc")); assertTrue(pattern.accepts(Arrays.asList("abc"))); assertTrue(pattern.accepts(Arrays.asList("abc", "abcd"))); @@ -120,15 +109,16 @@ public class StandardPatternsTest extends UsefulTestCase { assertTrue(pattern.accepts(Arrays.asList("bc", "abc"))); } - public void testFilter() throws Throwable { - ElementPattern pattern = collection(String.class).filter(string().endsWith("x"), collection(String.class).all(string().startsWith("abc"))); + public void testFilter() { + ElementPattern pattern = + collection(String.class).filter(string().endsWith("x"), collection(String.class).all(string().startsWith("abc"))); assertTrue(pattern.accepts(Arrays.asList("abc"))); assertTrue(pattern.accepts(Arrays.asList("abc", "abcd"))); assertFalse(pattern.accepts(Arrays.asList("bcx", "bcd"))); assertTrue(pattern.accepts(Arrays.asList("abcx", "abc"))); } - public void testFirst() throws Throwable { + public void testFirst() { ElementPattern pattern = collection(String.class).first(string().startsWith("abc")); assertFalse(pattern.accepts(Arrays.<String>asList())); assertTrue(pattern.accepts(Arrays.asList("abc"))); @@ -138,7 +128,7 @@ public class StandardPatternsTest extends UsefulTestCase { assertFalse(pattern.accepts(Arrays.asList("bc", "abc"))); } - public void testLast() throws Throwable { + public void testLast() { //collection(String.class) ElementPattern pattern = collection(String.class).last(string().startsWith("abc")); @@ -150,7 +140,7 @@ public class StandardPatternsTest extends UsefulTestCase { assertTrue(pattern.accepts(Arrays.asList("bc", "abc"))); } - public void testSize() throws Throwable { + public void testSize() { final CollectionPattern<String> filter = collection(String.class); assertTrue(filter.size(0).accepts(Arrays.<String>asList())); assertFalse(filter.size(0).accepts(Arrays.asList("abc"))); @@ -165,7 +155,7 @@ public class StandardPatternsTest extends UsefulTestCase { assertTrue(filter.size(2).accepts(Arrays.asList("abc", "abc"))); } - public void testEmpty() throws Throwable { + public void testEmpty() { final CollectionPattern<String> filter = collection(String.class); assertTrue(filter.empty().accepts(Arrays.<String>asList())); assertFalse(filter.empty().accepts(Arrays.asList("abc"))); @@ -176,7 +166,7 @@ public class StandardPatternsTest extends UsefulTestCase { assertTrue(not(filter.empty()).accepts(Arrays.asList("abc", "abc"))); } - public void testSave() throws Throwable { + public void testSave() { Key<String> key = Key.create("abc"); final ProcessingContext context = new ProcessingContext(); assertFalse(string().contains("abc").save(key).accepts(null)); @@ -189,6 +179,4 @@ public class StandardPatternsTest extends UsefulTestCase { assertTrue(string().contains("abc").save(key).accepts(s, context)); assertSame(s, context.get(key)); } - - } |