diff options
author | Klaus Aehlig <aehlig@google.com> | 2016-08-02 10:06:07 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2016-08-02 11:16:46 +0000 |
commit | e52813bff60b81188c5042e936bfb5249340cc58 (patch) | |
tree | 7abcf4f77b4a6881e4c59b2ec779908972e9d2e3 /src/test/java/com/google/devtools/build/lib | |
parent | 8f08c63365d1e72d5f70285294d4df774d693a68 (diff) |
ExperimentalStateTracker: make suffix gracefully handle negative length
When requested to produce a suffix of a string of a string
of a given length, gracefully handle the case where the requested
length is negative---simply return the empty string in
this case. While there, mark this static method as such; also
increase visibility to default as it is generally useful and
should be tested as an interface of this class.
--
Change-Id: I821966f7ba3828809bc6d000358803c131740ec9
Reviewed-on: https://bazel-review.googlesource.com/#/c/4223
MOS_MIGRATED_REVID=129080284
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java index a416abfee0..a0f41d523d 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.runtime; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; @@ -38,15 +39,13 @@ import com.google.devtools.build.lib.util.io.LoggingTerminalWriter; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.view.test.TestStatus.BlazeTestStatus; - +import java.io.IOException; +import java.util.concurrent.TimeUnit; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mockito; -import java.io.IOException; -import java.util.concurrent.TimeUnit; - /** * Tests {@link ExperimentalStateTracker}. */ @@ -562,4 +561,12 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { "Progress bar should contain 'Other action', but was:\n" + output, output.contains("Other action")); } + + + @Test + public void testSuffix() throws Exception { + assertEquals("bar", ExperimentalStateTracker.suffix("foobar", 3)); + assertEquals("", ExperimentalStateTracker.suffix("foo", -2)); + assertEquals("foobar", ExperimentalStateTracker.suffix("foobar", 200)); + } } |