|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.apache.commons.csv.issues; |
| 21 | + |
| 22 | +import static org.apache.commons.csv.CsvAssertions.assertValuesEquals; |
| 23 | + |
| 24 | +import java.io.BufferedReader; |
| 25 | +import java.io.IOException; |
| 26 | +import java.nio.charset.StandardCharsets; |
| 27 | +import java.nio.file.Files; |
| 28 | +import java.nio.file.Paths; |
| 29 | +import java.util.Iterator; |
| 30 | + |
| 31 | +import org.apache.commons.csv.CSVFormat; |
| 32 | +import org.apache.commons.csv.CSVParser; |
| 33 | +import org.apache.commons.csv.CSVRecord; |
| 34 | +import org.junit.jupiter.api.Test; |
| 35 | + |
| 36 | +/** |
| 37 | + * Tests https://issues.apache.org/jira/browse/CSV-254. |
| 38 | + */ |
| 39 | +class JiraCsv254Test { |
| 40 | + |
| 41 | + @Test |
| 42 | + void test() throws IOException { |
| 43 | + final CSVFormat csvFormat = CSVFormat.POSTGRESQL_CSV; |
| 44 | + try (BufferedReader reader = Files.newBufferedReader(Paths.get("src/test/resources/org/apache/commons/csv/CSV-254/csv-254.csv"), |
| 45 | + StandardCharsets.UTF_8); CSVParser parser = csvFormat.parse(reader)) { |
| 46 | + final Iterator<CSVRecord> csvRecords = parser.iterator(); |
| 47 | + assertValuesEquals(new String[] { "AA", "33", null }, csvRecords.next()); |
| 48 | + assertValuesEquals(new String[] { "AA", null, "" }, csvRecords.next()); |
| 49 | + assertValuesEquals(new String[] { null, "33", "CC" }, csvRecords.next()); |
| 50 | + } |
| 51 | + } |
| 52 | +} |
0 commit comments