import junit.framework.TestCase;
public class CDXFormatTest extends TestCase {
public void testParseSpec() {
CaptureSearchResult c;
CDXFormat f = OKFormat(" CDX a V");
c = OKParse(f,"http://foo.com 12");
assertEquals("http://foo.com",c.getOriginalUrl());
assertEquals(c.getOffset(), 12);
f = OKFormat(" CDX a V k");
c = OKParse(f,"http://foo.com 12 10");
assertEquals("http://foo.com",c.getOriginalUrl());
assertEquals(12,c.getOffset());
assertEquals("10",c.getDigest());
exceptionFormat("CDX a k");
exceptionFormat("\tCDX a k");
exceptionFormat("\tCDX a k ");
exceptionFormat(" CDX\ta k");
exceptionFormat(" CDX\ta k\t");
exceptionFormat(" CDX\ta\tk\t");
f = OKFormat(" CDX\ta\tV\tk");
c = OKParse(f,"http://foo.com\t12\t10");
assertEquals("http://foo.com",c.getOriginalUrl());
assertEquals(12,c.getOffset());
assertEquals("10",c.getDigest());
c = OKParse(f,"http://foo .com\t12\t10");
assertEquals("http://foo .com",c.getOriginalUrl());
assertEquals(12,c.getOffset());
assertEquals("10",c.getDigest());
}