### Question:
Span implements Cloneable, Serializable, Comparable<Span> { public static Span fromString(String str) { str = str.trim(); int sadj = 0; if (str.startsWith("(")) sadj = 1; else if (str.startsWith("[")) sadj = 0; else throw new IllegalArgumentException("bad span string: "+str); int eadj = 0; if (str.endsWith(")")) eadj = 0; else if (str.endsWith("]")) eadj = 1; else throw new IllegalArgumentException("bad span string: "+str); int mid = str.indexOf(INTERVAL_SEP_SYMBOL); String begin = str.substring(1, mid).trim(); String end = str.substring(mid + 1, str.length()-1).trim(); try { return new Span(Integer.parseInt(begin)+sadj, Integer.parseInt(end)+eadj); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("bad span string: "+str); } } Span();  Span(int first, int last);  Span(Span span); String substring(String text); String substring(String text, int offset); String substringLimit(String whole); boolean overlaps(Span s); static boolean overlap(Iterable<? extends Span> spans); static Span coveringSpan(Span... spans); static Span coveringSpan(Iterable<? extends Span> spans); boolean overlaps(int s, int e); static boolean overlaps(int s1, int e1, int s2, int e2); static boolean contains(int s1, int e1, int s2, int e2); boolean contains(Span s); boolean contains(int ndx); boolean contains(int otherStart, int otherEnd); boolean properContains(Span s); boolean crosses(Span s); @Override String toString(); static String toString(Span span); static Span fromString(String str); @Override int hashCode(); @Override boolean equals(Object obj); static int sumLength(Span s1, Span s2); int distanceTo(Span s); boolean fix(int minStart, int maxEnd); static String replaceAll(String source, Map<Span,String> replacements); void addOffset(int offset); int whichSegment(List<? extends Span> segments); double snapToSegmentation(List<? extends Span> toks); static Span toSegmentSpan(Span charSpan, List<? extends Span> segments); static Span toSegmentSpan(Span charSpan, List<? extends Span> segments, boolean forceNonEmpty); static List<Span> toSegmentSpans(Iterable<? extends Span> spans, List<? extends Span> segments); static ArrayList<Span> complement(List<Span> spans, int from, int to); static int firstStart(Iterable<? extends Span> spans); static int lastEnd(Iterable<? extends Span> spans); static String compressSpace(String source, Collection<Span> spans); static String highlight(String source, Span span, String begin, String end); static String highlight(String source, Span span, String begin, String end, int offset); static String highlightAll(String source, List<? extends Span> spans, String begin, String end); static String highlightAll(String source, List<? extends Span> spans, String begin, String end, int offset); static String highlightAll(String source, List<X> spans, Function<T,Pair<String,String>> beginEndMaker); static String highlightAll(String source, List<X> spans, Function<T,Pair<String,String>> beginEndMaker, int offset); Pair<String,List<Span>> inverseHighlight(String highlighted, String start, String end); boolean isValid(String str); Span clone(); int overlapLength(int otherStart, int otherEnd); int overlapLength(Span other); double overlapPercent(int otherStart, int otherEnd); double overlapPercent(Span other); int length(); int compareTo(Span s); static final char INTERVAL_SEP_SYMBOL; public int start; }### Answer:
@Test public void testFromStringAndEquals() { assertEquals(new Span(4 , 9), Span.fromString("( 3 , 9 )")); assertEquals(new Span(3 , 9), Span.fromString("[3, 9 )")); }
@Test(expected=IllegalArgumentException.class) public void testFormat() { Span.fromString("(3,A)"); }