diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java b/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java index ddf8dadda9..2d7d2f75f9 100644 --- a/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java +++ b/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java @@ -17,6 +17,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; import com.google.common.collect.Lists; +import com.google.devtools.build.lib.util.OptionsUtils.PathFragmentConverter; import com.google.devtools.build.lib.util.OptionsUtils.PathFragmentListConverter; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.Option; @@ -166,6 +167,10 @@ public class OptionsUtilsTest { return new PathFragmentListConverter().convert(input); } + private PathFragment convertOne(String input) throws Exception { + return new PathFragmentConverter().convert(input); + } + @Test public void emptyStringYieldsEmptyList() throws Exception { assertThat(convert("")).isEqualTo(list()); @@ -183,13 +188,24 @@ public class OptionsUtilsTest { @Test public void multiplePaths() throws Exception { - assertThat(convert("foo:/bar/baz:.:/tmp/bang")) + assertThat(convert("~/foo:foo:/bar/baz:.:/tmp/bang")) .containsExactly( - fragment("foo"), fragment("/bar/baz"), fragment("."), fragment("/tmp/bang")) + fragment(System.getProperty("user.home") + "/foo"), + fragment("foo"), + fragment("/bar/baz"), + fragment("."), + fragment("/tmp/bang")) .inOrder(); } @Test + public void singlePath() throws Exception { + assertThat(convertOne("foo")).isEqualTo(fragment("foo")); + assertThat(convertOne("foo/bar/baz")).isEqualTo(fragment("foo/bar/baz")); + assertThat(convertOne("~/foo")).isEqualTo(fragment(System.getProperty("user.home") + "/foo")); + } + + @Test public void valueisUnmodifiable() throws Exception { try { new PathFragmentListConverter().convert("value").add(PathFragment.create("other")); |