diff options
author | Andre Weinand | 2003-12-27 19:10:31 +0000 |
---|---|---|
committer | Andre Weinand | 2003-12-27 19:10:31 +0000 |
commit | 80540ea442787d2e4b4b0843dececa73cb0195f0 (patch) | |
tree | 4bec6364b0274461d248701b6702360c7ee76f83 /tests/org.eclipse.compare.tests | |
parent | 35bab511e86c0a92ce064206d6377f74be3e13c9 (diff) | |
download | eclipse.platform.team-80540ea442787d2e4b4b0843dececa73cb0195f0.tar.gz eclipse.platform.team-80540ea442787d2e4b4b0843dececa73cb0195f0.tar.xz eclipse.platform.team-80540ea442787d2e4b4b0843dececa73cb0195f0.zip |
added test cases for compare filter
Diffstat (limited to 'tests/org.eclipse.compare.tests')
6 files changed, 93 insertions, 18 deletions
diff --git a/tests/org.eclipse.compare.tests/.classpath b/tests/org.eclipse.compare.tests/.classpath index b26755e21..9501e31c8 100644 --- a/tests/org.eclipse.compare.tests/.classpath +++ b/tests/org.eclipse.compare.tests/.classpath @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="JUnit Tests"/> + <classpathentry kind="src" path="/org.junit"/> + <classpathentry kind="src" path="/org.eclipse.compare"/> + <classpathentry kind="src" path="/org.eclipse.core.runtime.compatibility"/> + <classpathentry kind="src" path="/org.eclipse.jface.text"/> + <classpathentry kind="src" path="/org.eclipse.jface"/> + <classpathentry kind="src" path="/org.eclipse.jdt.junit"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/tests/org.eclipse.compare.tests/.project b/tests/org.eclipse.compare.tests/.project index 8866a412d..da302d078 100644 --- a/tests/org.eclipse.compare.tests/.project +++ b/tests/org.eclipse.compare.tests/.project @@ -5,6 +5,7 @@ <projects> <project>org.eclipse.compare</project> <project>org.eclipse.core.runtime.compatibility</project> + <project>org.eclipse.jdt.junit</project> <project>org.eclipse.jface</project> <project>org.eclipse.jface.text</project> <project>org.junit</project> diff --git a/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java index 657015c90..45aa2f5bd 100644 --- a/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java +++ b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java @@ -1,16 +1,21 @@ -/* - * Created on May 22, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code Template - */ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ package org.eclipse.compare.tests; import junit.framework.Test; import junit.framework.TestSuite; + /** - * @author weinand + * Test some non-UI areas of the compare plugin. */ public class AllTests { @@ -18,6 +23,7 @@ public class AllTests { TestSuite suite= new TestSuite("Test for org.eclipse.compare.tests"); //$NON-NLS-1$ //$JUnit-BEGIN$ suite.addTestSuite(DocLineComparatorTest.class); + suite.addTestSuite(FilterTest.class); //$JUnit-END$ return suite; } diff --git a/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/DocLineComparatorTest.java b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/DocLineComparatorTest.java index c353798f6..dea402c0b 100644 --- a/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/DocLineComparatorTest.java +++ b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/DocLineComparatorTest.java @@ -1,9 +1,13 @@ -/* - * Created on May 22, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code Template - */ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ package org.eclipse.compare.tests; import junit.framework.Assert; @@ -14,9 +18,6 @@ import org.eclipse.compare.rangedifferencer.IRangeComparator; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; -/** - * @author weinand - */ public class DocLineComparatorTest extends TestCase { public DocLineComparatorTest(String name) { @@ -68,5 +69,4 @@ public class DocLineComparatorTest extends TestCase { Assert.assertTrue(comp1.rangesEqual(0, comp2, 0)); } - } diff --git a/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/FilterTest.java b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/FilterTest.java new file mode 100644 index 000000000..2e2ff4b38 --- /dev/null +++ b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/FilterTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.compare.tests; + +import org.eclipse.compare.internal.CompareFilter; + +import junit.framework.*; +import junit.framework.TestCase; + +public class FilterTest extends TestCase { + + CompareFilter fFilter; + + public FilterTest(String name) { + super(name); + } + + public void testFilterFile() { + CompareFilter f= new CompareFilter(); + f.setFilters("*.class"); + Assert.assertTrue("file foo.class should be filtered", f.filter("foo.class", false, false)); + Assert.assertFalse("file foo.java shouldn't be filtered", f.filter("foo.java", false, false)); + } + + public void testFilterDotFile() { + CompareFilter f= new CompareFilter(); + f.setFilters(".cvsignore"); + Assert.assertTrue("file .cvsignore should be filtered", f.filter(".cvsignore", false, false)); + Assert.assertFalse("file foo.cvsignore shouldn't be filtered", f.filter("foo.cvsignore", false, false)); + } + + public void testFilterFolder() { + CompareFilter f= new CompareFilter(); + f.setFilters("bin/"); + Assert.assertTrue("folder bin should be filtered", f.filter("bin", true, false)); + Assert.assertFalse("file bin shouldn't be filtered", f.filter("bin", false, false)); + } + + public void testMultiFilter() { + CompareFilter f= new CompareFilter(); + f.setFilters("*.class, .cvsignore, bin/"); + Assert.assertTrue("file foo.class should be filtered", f.filter("foo.class", false, false)); + Assert.assertFalse("file foo.java shouldn't be filtered", f.filter("foo.java", false, false)); + Assert.assertTrue("file .cvsignore should be filtered", f.filter(".cvsignore", false, false)); + Assert.assertFalse("file foo.cvsignore shouldn't be filtered", f.filter("foo.cvsignore", false, false)); + Assert.assertTrue("folder bin should be filtered", f.filter("bin", true, false)); + Assert.assertFalse("file bin shouldn't be filtered", f.filter("bin", false, false)); + } + + public void testVerify() { + //Assert.assertNull("filters don't verify", Filter.validateResourceFilters("*.class, .cvsignore, bin/")); + //Assert.assertNotNull("filters shouldn't verify", Filter.validateResourceFilters("bin//")); + } +} diff --git a/tests/org.eclipse.compare.tests/plugin.xml b/tests/org.eclipse.compare.tests/plugin.xml index 46e43f51b..aec5eabd2 100644 --- a/tests/org.eclipse.compare.tests/plugin.xml +++ b/tests/org.eclipse.compare.tests/plugin.xml @@ -18,6 +18,7 @@ <import plugin="org.eclipse.core.runtime.compatibility"/> <import plugin="org.eclipse.jface.text"/> <import plugin="org.eclipse.jface"/> + <import plugin="org.eclipse.jdt.junit"/> </requires> |