forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/test/java/seedu/weme/model/path/DirectoryPathTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package seedu.weme.model.path; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.weme.testutil.Assert.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.weme.model.meme.Description; | ||
import seedu.weme.testutil.TestUtil; | ||
|
||
class DirectoryPathTest { | ||
|
||
private static final String VALID_SANDBOX_DIRECTORY = TestUtil.getSandboxFolder().toString(); | ||
private static final String VALID_SANDBOX_DIRECTORY_2 = TestUtil.getSecondSandboxFolder().toString(); | ||
private static final String INVALID_SANDBOX_DIRECTORY = TestUtil.getInvalidSandboxFolder().toString(); | ||
private static final String SAMPLE_DESCRIPTION = "Sample Description"; | ||
|
||
@Test | ||
public void constructor_null_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new DirectoryPath(null)); | ||
} | ||
|
||
@Test | ||
public void isValidDirectoryPath() { | ||
// null directory path | ||
assertThrows(NullPointerException.class, () -> DirectoryPath.isValidDirectoryPath(null)); | ||
|
||
// valid directory path | ||
assertTrue(DirectoryPath.isValidDirectoryPath("")); // empty string | ||
assertTrue(DirectoryPath.isValidDirectoryPath(VALID_SANDBOX_DIRECTORY)); // valid directory path | ||
assertFalse(DirectoryPath.isValidDirectoryPath(INVALID_SANDBOX_DIRECTORY)); // invalid directory path | ||
} | ||
|
||
@Test | ||
public void equals() { | ||
final DirectoryPath directoryPath = new DirectoryPath(VALID_SANDBOX_DIRECTORY); | ||
|
||
// same values -> returns true | ||
assertTrue(directoryPath.equals(new DirectoryPath(VALID_SANDBOX_DIRECTORY))); | ||
|
||
// same object -> returns true | ||
assertTrue(directoryPath.equals(directoryPath)); | ||
|
||
// null -> returns false | ||
assertFalse(directoryPath.equals(null)); | ||
|
||
// different types -> returns false | ||
assertFalse(directoryPath.equals(new Description(SAMPLE_DESCRIPTION))); | ||
|
||
// different paths -> returns false | ||
assertFalse(directoryPath.equals(new DirectoryPath(VALID_SANDBOX_DIRECTORY_2))); | ||
} | ||
|
||
} |