@@ -688,7 +688,7 @@ public void testHeaderComment() throws Exception {
688688 public void testHeaderMissing () throws Exception {
689689 final Reader in = new StringReader ("a,,c\n 1,2,3\n x,y,z" );
690690
691- final Iterator <CSVRecord > records = CSVFormat .DEFAULT .withHeader ().parse (in ).iterator ();
691+ final Iterator <CSVRecord > records = CSVFormat .DEFAULT .withHeader ().withAllowMissingColumnNames (). parse (in ).iterator ();
692692
693693 for (int i = 0 ; i < 2 ; i ++) {
694694 assertTrue (records .hasNext ());
@@ -702,22 +702,28 @@ public void testHeaderMissing() throws Exception {
702702
703703 @ Test
704704 public void testHeaderMissingWithNull () throws Exception {
705- final Reader in = new StringReader ("a,,c,,d \n 1,2,3,4\n x, y,z,zz " );
705+ final Reader in = new StringReader ("a,,c,,e \n 1,2,3,4,5 \n v,w,x, y,z" );
706706 CSVFormat .DEFAULT .withHeader ().withNullString ("" ).withAllowMissingColumnNames ().parse (in ).iterator ();
707707 }
708708
709709 @ Test
710710 public void testHeadersMissing () throws Exception {
711- final Reader in = new StringReader ("a,,c,,d \n 1,2,3,4\n x, y,z,zz " );
711+ final Reader in = new StringReader ("a,,c,,e \n 1,2,3,4,5 \n v,w,x, y,z" );
712712 CSVFormat .DEFAULT .withHeader ().withAllowMissingColumnNames ().parse (in ).iterator ();
713713 }
714714
715715 @ Test
716716 public void testHeadersMissingException () {
717- final Reader in = new StringReader ("a,,c,,d \n 1,2,3,4\n x, y,z,zz " );
717+ final Reader in = new StringReader ("a,,c,,e \n 1,2,3,4,5 \n v,w,x, y,z" );
718718 assertThrows (IllegalArgumentException .class , () -> CSVFormat .DEFAULT .withHeader ().parse (in ).iterator ());
719719 }
720720
721+ @ Test
722+ public void testHeadersMissingOneColumnException () throws Exception {
723+ final Reader in = new StringReader ("a,,c,d,e\n 1,2,3,4,5\n v,w,x,y,z" );
724+ assertThrows (IllegalArgumentException .class , () -> CSVFormat .DEFAULT .withHeader ().parse (in ).iterator ());
725+ }
726+
721727 @ Test
722728 public void testIgnoreCaseHeaderMapping () throws Exception {
723729 final Reader reader = new StringReader ("1,2,3" );
0 commit comments