Ejemplo n.º 1
0
        public virtual void test_of_comment_blank_with_header()
        {
            CsvFile csvFile = CsvFile.of(CharSource.wrap(CSV2), true);
            ImmutableList <string> headers = csvFile.headers();

            assertEquals(headers.size(), 2);
            assertEquals(headers.get(0), "h1");
            assertEquals(headers.get(1), "h2");
            assertEquals(csvFile.rows().size(), 1);
            assertEquals(csvFile.rowCount(), 1);
            assertEquals(csvFile.row(0).lineNumber(), 5);

            assertEquals(csvFile.row(0).fieldCount(), 2);
            assertEquals(csvFile.row(0).field(0), "r21");
            assertEquals(csvFile.row(0).field(1), "r22");
            assertEquals(csvFile.rows().get(0), csvFile.row(0));
        }
Ejemplo n.º 2
0
        public virtual void test_of_lists_noHeaderNoRows()
        {
            IList <string>          headers = Collections.emptyList();
            IList <IList <string> > rows    = Collections.emptyList();
            CsvFile csvFile = CsvFile.of(headers, rows);

            assertEquals(csvFile.headers(), headers);
            assertEquals(csvFile.rows(), rows);
        }
Ejemplo n.º 3
0
        public virtual void test_of_lists_header()
        {
            IList <string>          headers = Arrays.asList("1", "2");
            IList <IList <string> > rows    = Arrays.asList(Arrays.asList("a", "x"), Arrays.asList("b", "y"));
            CsvFile csvFile = CsvFile.of(headers, rows);

            assertEquals(csvFile.headers(), headers);
            assertEquals(csvFile.rows().size(), 2);
            assertEquals(csvFile.row(0).fields(), Arrays.asList("a", "x"));
            assertEquals(csvFile.row(1).fields(), Arrays.asList("b", "y"));
        }