### Question:
FileReader implements Iterable<Elements> { @Override public FileReaderIterator iterator() { if ( this.tableElement == null ) { try { getTable(); } catch ( RuntimeException | Error e ) { throw e; } catch ( Exception e ) { throw new RuntimeException( e ); } } FileReaderIterator iterator = new FileReaderIterator( this.tableElement.select( "tr" ) ); if ( true ) { Elements headings = iterator.next( "th" ); if ( headings.size() == 0 ) { iterator = new FileReaderIterator( this.tableElement.select( "tr" ) ); Elements firstRow = iterator.next( "td" ); int i = 0; headings = new Elements(); for ( Element td : firstRow ) { Element th = td.clone(); th.tagName( "th" ); th.html( "col" + i++ ); headings.add( th ); } iterator = new FileReaderIterator( this.tableElement.select( "tr" ) ); } this.headings = headings; } return iterator; } FileReader( Source source, String selector, Integer index );  FileReader( Source source, String selector );  FileReader( Source source ); @Override FileReaderIterator iterator(); void close();  }### Answer:
@Test public void testFileReaderData() throws FileReaderException { final Source source = Sources.file( null, file( "build/test-classes/tableOK.html" ) ); FileReader t = new FileReader( source ); Iterator<Elements> i = t.iterator(); Elements row = i.next(); assertTrue( row.get( 2 ).text().equals( "R0C2" ) ); row = i.next(); assertTrue( row.get( 0 ).text().equals( "R1C0" ) ); }
@Test public void testFileReaderDataBadFile() throws FileReaderException { final Source source = Sources.file( null, file( "build/test-classes/tableNoTheadTbody.html" ) ); FileReader t = new FileReader( source ); Iterator<Elements> i = t.iterator(); Elements row = i.next(); assertTrue( row.get( 2 ).text().equals( "R0C2" ) ); row = i.next(); assertTrue( row.get( 0 ).text().equals( "R1C0" ) ); }
@Test public void testFileReaderDataNoTh() throws FileReaderException { final Source source = Sources.file( null, file( "build/test-classes/tableNoTH.html" ) ); FileReader t = new FileReader( source ); Iterator<Elements> i = t.iterator(); Elements row = i.next(); assertTrue( row.get( 2 ).text().equals( "R0C2" ) ); }