File tree Expand file tree Collapse file tree
main/java/com/example/solidconnection/common/util
test/java/com/example/solidconnection/common/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,9 +30,11 @@ private void validate(String[] lines) {
3030 }
3131
3232 private List <String > parseRow (String line ) {
33- return Arrays .stream (line .split ("\\ |" ))
33+ String stripped = line .trim ();
34+ if (stripped .startsWith ("|" )) stripped = stripped .substring (1 );
35+ if (stripped .endsWith ("|" )) stripped = stripped .substring (0 , stripped .length () - 1 );
36+ return Arrays .stream (stripped .split ("\\ |" ))
3437 .map (String ::trim )
35- .filter (s -> !s .isEmpty ())
3638 .collect (Collectors .toList ());
3739 }
3840
Original file line number Diff line number Diff line change @@ -40,6 +40,22 @@ class 정상_파싱 {
4040 .doesNotContainKey ("TOEIC" );
4141 }
4242
43+ @ Test
44+ void 중간_빈_셀이_있어도_이후_컬럼이_올바르게_매핑된다 () {
45+ String markdown = """
46+ | 대학명 | 인원 | TOEIC |
47+ |--------|------|-------|
48+ | MIT | | 800 |
49+ """ ;
50+
51+ List <Map <String , String >> rows = parser .parse (markdown );
52+
53+ assertThat (rows .get (0 ))
54+ .containsEntry ("대학명" , "MIT" )
55+ .doesNotContainKey ("인원" )
56+ .containsEntry ("TOEIC" , "800" );
57+ }
58+
4359 @ Test
4460 void 빈_셀은_결과_맵에_포함되지_않는다 () {
4561 String markdown = """
You can’t perform that action at this time.
0 commit comments