// Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
//   private final static int optimal = 100;
//   private final int myLimit;
// 
//   public TextUtil() {
//     this(-1);
//   }
// 
//   public TextUtil(int limit) {
//     this.myLimit = limit < 0 ? optimal : limit;
//   }
// 
//   public String insertLineCuts(final String s) {
//     if (s == null || s.length() <= myLimit) return s;
//     final int idx = s.substring(0, myLimit).lastIndexOf(' ');
//     if (idx > 0) {
//       return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
//     }
//     final int idx2 = s.indexOf(' ', myLimit);
//     if (idx2 == -1) return s;
//     return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
//   }
// }


import org.github.irengrig.fossil4idea.util.TextUtil;
import org.junit.Test;
package org.github.irengrig.test;


/**
 * Created by Irina.Chernushina on 5/29/2014.
 */
public class TextUtilTest {
  @Test
  public void testSimple() throws Exception {
    final String s = "The ui command is intended for accessing the web interface from a local desktop. " +
            "The ui command binds to the loopback IP address only (and thus makes the web interface visible only on the local machine)" +
            " and it automatically start your web browser pointing at the server. " +
            "someverylongfortest13213243254354365465765765 " +
            "For cross-machine collaboration, use the server command, which binds on all IP addresses and does not try to start a web browser.";
    // test is for it's not eternal
// Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
//   private final static int optimal = 100;
//   private final int myLimit;
// 
//   public TextUtil() {
//     this(-1);
//   }
// 
//   public TextUtil(int limit) {
//     this.myLimit = limit < 0 ? optimal : limit;
//   }
// 
//   public String insertLineCuts(final String s) {
//     if (s == null || s.length() <= myLimit) return s;
//     final int idx = s.substring(0, myLimit).lastIndexOf(' ');
//     if (idx > 0) {
//       return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
//     }
//     final int idx2 = s.indexOf(' ', myLimit);
//     if (idx2 == -1) return s;
//     return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
//   }
// }


// Path: test/org/github/irengrig/test/TextUtilTest.java
import org.github.irengrig.fossil4idea.util.TextUtil;
import org.junit.Test;

package org.github.irengrig.test;


/**
 * Created by Irina.Chernushina on 5/29/2014.
 */
public class TextUtilTest {
  @Test
  public void testSimple() throws Exception {
    final String s = "The ui command is intended for accessing the web interface from a local desktop. " +
            "The ui command binds to the loopback IP address only (and thus makes the web interface visible only on the local machine)" +
            " and it automatically start your web browser pointing at the server. " +
            "someverylongfortest13213243254354365465765765 " +
            "For cross-machine collaboration, use the server command, which binds on all IP addresses and does not try to start a web browser.";
    // test is for it's not eternal
    final String cuts = new TextUtil(15).insertLineCuts(s);