package ucar.nc2.util;

import org.junit.Ignore;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Test  TableParser.readTable
 *
 * @author caron
 * @since 4/19/12
 */
public class TestTableParser {

    ////////////////////////////////////////////////////////////////////////////////////
  static final String testName3 = "/resources/nj22/tables/nexrad.tbl";
  static final String testRepeat = "C:\\data\\ghcnm\\ghcnm.v3.0.0-beta1.20101207.qae.dat"; // LOOK put this into cdmUnitTest

  @Test
  public void testReadNexradTable() throws IOException {
    Class c = TableParser.class;
    InputStream is = c.getResourceAsStream(testName3);
    List<TableParser.Record> recs = TableParser.readTable(is, "3,15,54,60d,67d,73d", 50000);
    for (TableParser.Record record : recs) {
      for (int j = 0; j < record.values.size(); j++) {
        Object s = record.values.get(j);
        System.out.print(" " + s.toString());
      }
      System.out.println();
    }
  }

  @Test
  @Ignore("ghcnm.v3.0.0-beta1.20101207.qae.dat isn't in /share/testdata")
  public void testReadgGghcnmTable() throws IOException {
    List<TableParser.Record> recs = TableParser.readTable(testRepeat, "11L,15i,19,(24i,25,26,27)*10", 5);
    for (TableParser.Record record : recs) {
      for (int j = 0; j < record.values.size(); j++) {
        Object s = record.values.get(j);
        System.out.print(" " + s.toString());
      }
      System.out.println();
    }
  }


}

@@ -15,24 +15,50 @@
 c2.util;%0D%0A%0D%0A
+import org.junit.Assert;%0D%0A
 import org.j
@@ -835,33 +835,30 @@
 %22, 50000);%0D%0A
+%0D%0A
     
-for (
 TableParser.
@@ -871,125 +871,413 @@
  rec
-ord : recs) %7B%0D%0A      for (int j = 0; j %3C record.values.size(); j++) %7B%0D%0A        Object s = record.value
+ = recs.get(0);%0D%0A    Assert.assertEquals(%22TLX%22, rec.get(0));%0D%0A    Assert.assertEquals(%22      000001%22, rec.get(1));%0D%0A    Assert.assertEquals(%22 OKLAHOMA_CITY/Norman             OK US%22, rec.get(2));%0D%0A    Assert.assertEquals(3532.0, (Double)rec.get(3), 0.1);%0D%0A    Assert.assertEquals(-9727.0, (Double)rec.get(4), 0.1);%0D%0A    Assert.assertEquals(370.0, (Double)rec.get(5), 0.1);%0D%0A%0D%0A    rec = rec
 s.get(
-j
+20
 );%0D%0A    
     
@@ -1276,94 +1276,359 @@
     
-    System.out.print(%22 %22 + s.toString());%0D%0A      %7D
+Assert.assertEquals(%22TWX%22, rec.get(0));%0D%0A    Assert.assertEquals(%22      000554%22, rec.get(1));%0D%0A    Assert.assertEquals(%22 TOPEKA/Alma                      KS US%22, rec.get(2));%0D%0A    Assert.assertEquals(3898.0, (Double)rec.get(3), 0.1);
 %0D%0A    
- 
- System.out.println();%0D%0A    %7D
+Assert.assertEquals(-9622.0, (Double)rec.get(4), 0.1);%0D%0A    Assert.assertEquals(417.0, (Double)rec.get(5), 0.1);
 %0D%0A  
@@ -1701,23 +1701,12 @@
  in 
-/share/testdata
+repo
 %22)%0D%0A

Convert testReadNexradTable into actual test.