FileUtilTest: Add test for Windows path #976
Conversation
Click here to submit a new iteration when this PR is ready for review. See this repository's contribution guide for more information. |
c148460
to
75e1d33
Compare
Currently, FileUtilTest#isValidPath() only tests for isValidPath for a linux path. However, our users can also develop and use AB4 on a Windows PC. To provide assurance that our FileUtil#isValidPath(String) method works on Windows computers as well, we should add coverage to test for paths on Windows. Hence, let's add another test to ensure that FileUtil#isValidPath returns the correct result for a valid path in the Windows naming convention.
75e1d33
to
2b08c41
Compare
v1@sijie123 submitted v1 for review. Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level4.git refs/pr/976/1/head:BRANCHNAME where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileUtilTest: Add test for Windows path Currently, FileUtilTest#isValidPath() only tests for isValidPath for a linux path.
I don't quite follow. valid/file/path
is a valid Windows path as well, no? It is semantically the same as well.
Oh, it's also a valid Mac path as well :-P
However, our users can also develop and use AB4 on a Windows PC. To provide assurance that our FileUtil#isValidPath(String) method works on Windows computers as well, we should add coverage to test for paths on Windows. Hence, let's add another test to ensure that FileUtil#isValidPath returns the correct result for a valid path in the Windows naming convention.
@@ -12,7 +12,8 @@ | |||
@Test | |||
public void isValidPath() { | |||
// valid path | |||
assertTrue(FileUtil.isValidPath("valid/file/path")); | |||
assertTrue(FileUtil.isValidPath("valid/file/path")); //Linux | |||
assertTrue(FileUtil.isValidPath("valid\\file\\path")); //Windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the idea of the test since valid\file\path
is not just a "Windows path", It is a valid Linux path as well. So, it's not correct to annotate them with the // Linux
and // Windows
comments.
Also, compared to valid/file/path
, valid\file\path
has different meanings on Windows and Linux. On Linux it just means "a file with the name valid\file\path
", which is probably not the intention here.
Anyway, as the very sparse "invalid path" test case below hints, these are only simple smoke tests to check to see if isValidPath()
is properly wired up to Paths.get()
. It is assumed that Paths.get()
is implemented correctly. So I don't really see the value in adding more tests.
I think I was kinda loose on my Windows/Linux terminology use. In any case, I agree with you in that the method is essentially a hook to I will close this issue. |
Currently, FileUtilTest#isValidPath() only tests for isValidPath for a linux path. However, our users can also develop and use AB4 on a Windows PC. To provide assurance that our FileUtil#isValidPath(String) method works on Windows computers as well, we should add coverage to test for paths on Windows.
Hence, let's add another test to ensure that FileUtil#isValidPath returns the correct result for a valid path in the Windows naming convention.