You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/05/21 12:41:41 UTC

[commons-lang] branch master updated: - Add testToSplitString() - Use topWatch.createStarted();

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new c0f5853  - Add testToSplitString() - Use topWatch.createStarted();
c0f5853 is described below

commit c0f585308188c0647020f74bd1ca7abef0f29b92
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 21 08:41:36 2019 -0400

    - Add testToSplitString()
    - Use topWatch.createStarted();
---
 .../apache/commons/lang3/time/StopWatchTest.java   | 25 +++++++++++++++-------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
index 18d9e97..b3bf035 100644
--- a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java
@@ -166,8 +166,7 @@ public class StopWatchTest {
 
     @Test
     public void testLang315() {
-        final StopWatch watch = new StopWatch();
-        watch.start();
+        final StopWatch watch = StopWatch.createStarted();
         try {
             Thread.sleep(200);
         } catch (final InterruptedException ex) {
@@ -203,8 +202,7 @@ public class StopWatchTest {
     //-----------------------------------------------------------------------
     @Test
     public void testStopWatchSimple() {
-        final StopWatch watch = new StopWatch();
-        watch.start();
+        final StopWatch watch = StopWatch.createStarted();
         try {
             Thread.sleep(550);
         } catch (final InterruptedException ex) {
@@ -238,8 +236,7 @@ public class StopWatchTest {
 
     @Test
     public void testStopWatchSplit() {
-        final StopWatch watch = new StopWatch();
-        watch.start();
+        final StopWatch watch = StopWatch.createStarted();
         try {
             Thread.sleep(550);
         } catch (final InterruptedException ex) {
@@ -277,8 +274,7 @@ public class StopWatchTest {
 
     @Test
     public void testStopWatchSuspend() {
-        final StopWatch watch = new StopWatch();
-        watch.start();
+        final StopWatch watch = StopWatch.createStarted();
         try {
             Thread.sleep(550);
         } catch (final InterruptedException ex) {
@@ -305,4 +301,17 @@ public class StopWatchTest {
         assertTrue(totalTime >= 1000);
         assertTrue(totalTime < 1300);
     }
+
+    @Test
+    public void testToSplitString() {
+        final StopWatch watch = StopWatch.createStarted();
+        try {
+            Thread.sleep(550);
+        } catch (final InterruptedException ex) {
+            // ignore
+        }
+        watch.split();
+        final String splitStr = watch.toSplitString();
+        assertEquals(splitStr.length(), 12, "Formatted split string not the correct length");
+    }
 }