// Copyright (c) Keith D Gregory, all rights reserved
package com.kdgregory.example.coverage;

import junit.framework.TestCase;

/**
 *  Demonstrates that 100% coverage doesn't mean that you handle invalid cases.
 *
 *  If you have the EclEmma plugin installed for Eclipse, you can simply run
 *  using "Coverage As ... JUnit Test". Otherwise, you'll have to rename and
 *  fit into a build directory.
 */
public class ExceptionExample
extends TestCase
{
    public static String extractMiddle(String s)
    {
        int idx1 = s.indexOf(':');
        int idx2 = s.indexOf(':', idx1 + 1);
        return s.substring(idx1 + 1, idx2);
    }


    public void testExtractMiddle() throws Exception
    {
        assertEquals("bar", extractMiddle("foo:bar:baz"));
    }
}
