Skip to content

Commit

Permalink
Ajouts de test unitaires
Browse files Browse the repository at this point in the history
  • Loading branch information
Dim145 committed Nov 18, 2020
1 parent 4b8befa commit 145bb04
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .idea/libraries/junit_junit_4_13_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Files_renamer.iml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="junit:junit:4.13.1" level="project" />
</component>
</module>
Binary file added lib/hamcrest-core-1.3.jar
Binary file not shown.
Binary file added lib/junit-4.13.1.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions src/renameFiles/metier/Metier.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public Metier( Controleur ctrl )
this.blockIfNotMathPatern = true;
}

public void setAcceptedExtensions( String extensions )
public boolean setAcceptedExtensions( String extensions )
{
if( extensions == null || extensions.length() < 1) return;
if( extensions == null || extensions.length() < 1) return false;

this.acceptedExtension.clear();

Expand All @@ -36,6 +36,8 @@ public void setAcceptedExtensions( String extensions )

this.acceptedExtension.add(s.trim());
}

return this.acceptedExtension.size() > 0;
}

public void renameWithPaterneInPath( String path, String patern )
Expand Down
36 changes: 36 additions & 0 deletions tests/TestMetier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import junit.framework.TestCase;
import renameFiles.metier.Metier;

public class TestMetier extends TestCase
{
private Metier metier;

@Override
protected void setUp() throws Exception
{
super.setUp();

this.metier = new Metier(null);
}

@Override
protected void tearDown() throws Exception
{
super.tearDown();

this.metier = null;
}

public void testAcceptedExtensions() throws Exception
{
String[] extensions = {null, "", }; // cas faux car "null"

for ( String s : extensions )
assertFalse(this.metier.setAcceptedExtensions(s));

extensions = new String[]{",", ",,,", ", , , , , "}; // cas faux car vide

for ( String s : extensions )
assertFalse(this.metier.setAcceptedExtensions(s));
}
}

0 comments on commit 145bb04

Please sign in to comment.