diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-06-18 07:34:12 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-06-18 07:34:12 +0000 |
commit | 0c8b44743920959d428111a09b3fb2b7d458857b (patch) | |
tree | 3c674f3b504791a3d4175b9d1b484481e61576c1 /org.jacoco.core.test/src/org/jacoco/core/matcher | |
parent | 5c9e5a2b16c813bcdb8a501b418579b8ec03a2b5 (diff) | |
parent | 612756b6f243e250a93104aae170545dce9b8d49 (diff) | |
download | jacoco-0c8b44743920959d428111a09b3fb2b7d458857b.tar.gz |
release-request-c9e3b153-009d-4386-b83e-337752602795-for-git_oc-mr1-release-4111654 snap-temp-L22900000075285650
Change-Id: Id2895c30a099a3f2eed63a6898e34667c07e8e8b
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco/core/matcher')
-rw-r--r-- | org.jacoco.core.test/src/org/jacoco/core/matcher/IncludeExcludeMatcherTest.java | 75 | ||||
-rw-r--r-- | org.jacoco.core.test/src/org/jacoco/core/matcher/WildcardMatcherTest.java | 72 |
2 files changed, 147 insertions, 0 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/matcher/IncludeExcludeMatcherTest.java b/org.jacoco.core.test/src/org/jacoco/core/matcher/IncludeExcludeMatcherTest.java new file mode 100644 index 00000000..e0268956 --- /dev/null +++ b/org.jacoco.core.test/src/org/jacoco/core/matcher/IncludeExcludeMatcherTest.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Jeffry Gaston - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.matcher; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class IncludeExcludeMatcherTest { + + @Test + public void testEmpty() { + assertTrue(new IncludeExcludeMatcher<String>().apply("includeMe")); + } + + @Test + public void testSingleExclude() { + IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>() + .exclude(new WildcardMatcher("excluded")); + assertTrue(matcher.apply("included")); + assertFalse(matcher.apply("excluded")); + } + + @Test + public void testMultipleExcludes() { + IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>().exclude( + new WildcardMatcher("excluded")) + .exclude(new WildcardMatcher("excluded2")); + assertTrue(matcher.apply("included")); + assertFalse(matcher.apply("excluded")); + assertFalse(matcher.apply("excluded2")); + } + + @Test + public void testSingleInclude() { + IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>() + .include(new WildcardMatcher("include me")); + assertTrue(matcher.apply("include me")); + assertFalse(matcher.apply("not me")); + } + + @Test + public void testIncludesAndExcludes() { + IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>() + .include(new WildcardMatcher("inclusion1")) + .include(new WildcardMatcher("me too")) + .exclude(new WildcardMatcher("not me")) + .exclude(new WildcardMatcher("nope")); + assertTrue(matcher.apply("inclusion1")); + assertTrue(matcher.apply("me too")); + assertFalse(matcher.apply("not me")); + assertFalse(matcher.apply("nope")); + assertFalse(matcher.apply("other")); + } + + @Test + public void testExcludedInclusion() { + IncludeExcludeMatcher<String> matcher = new IncludeExcludeMatcher<String>() + .include(new WildcardMatcher("a")) + .exclude(new WildcardMatcher("a")); + assertFalse(matcher.apply("a")); + assertFalse(matcher.apply("b")); + } + +} diff --git a/org.jacoco.core.test/src/org/jacoco/core/matcher/WildcardMatcherTest.java b/org.jacoco.core.test/src/org/jacoco/core/matcher/WildcardMatcherTest.java new file mode 100644 index 00000000..baf1dc2b --- /dev/null +++ b/org.jacoco.core.test/src/org/jacoco/core/matcher/WildcardMatcherTest.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc R. Hoffmann - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.matcher; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class WildcardMatcherTest { + + @Test + public void testEmpty() { + assertTrue(new WildcardMatcher("").apply("")); + assertFalse(new WildcardMatcher("").apply("abc")); + } + + @Test + public void testExact() { + assertTrue(new WildcardMatcher("abc/def.txt").apply("abc/def.txt")); + } + + @Test + public void testCaseSensitive() { + assertFalse(new WildcardMatcher("abcdef").apply("abcDef")); + assertFalse(new WildcardMatcher("ABCDEF").apply("AbCDEF")); + } + + @Test + public void testQuote() { + assertFalse(new WildcardMatcher("rst.xyz").apply("rstAxyz")); + assertTrue(new WildcardMatcher("(x)+").apply("(x)+")); + } + + @Test + public void testWildcards() { + assertTrue(new WildcardMatcher("*").apply("")); + assertTrue(new WildcardMatcher("*").apply("java/lang/Object")); + assertTrue(new WildcardMatcher("*Test").apply("jacoco/MatcherTest")); + assertTrue(new WildcardMatcher("Matcher*").apply("Matcher")); + assertTrue(new WildcardMatcher("Matcher*").apply("MatcherTest")); + assertTrue(new WildcardMatcher("a*b*a").apply("a-b-b-a")); + assertFalse(new WildcardMatcher("a*b*a").apply("alaska")); + assertTrue(new WildcardMatcher("Hello?orld").apply("HelloWorld")); + assertFalse(new WildcardMatcher("Hello?orld").apply("HelloWWWorld")); + assertTrue(new WildcardMatcher("?aco*").apply("jacoco")); + } + + @Test + public void testMultiExpression() { + assertTrue(new WildcardMatcher("Hello:World").apply("World")); + assertTrue(new WildcardMatcher("Hello:World").apply("World")); + assertTrue(new WildcardMatcher("*Test:*Foo").apply("UnitTest")); + } + + @Test + public void testDollar() { + assertTrue(new WildcardMatcher("*$*").apply("java/util/Map$Entry")); + assertTrue(new WildcardMatcher("*$$$*") + .apply("org/example/Enity$$$generated123")); + } + +} |