From de1c20c9680f1680974b9fce0f083ad233c6792a Mon Sep 17 00:00:00 2001 From: satokuuuuuun <51846075+satokuuuuuun@users.noreply.github.com> Date: Tue, 10 Jan 2023 11:27:36 +0900 Subject: [PATCH 1/8] refactor(CsvReaderTest): change to use assertSoftly --- .../kotlincsv/client/CsvReaderTest.kt | 108 +++++++++++------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt index abb007a..45b554e 100644 --- a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt +++ b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt @@ -8,6 +8,7 @@ import com.github.doyaaaaaken.kotlincsv.util.CSVFieldNumDifferentException import com.github.doyaaaaaken.kotlincsv.util.CSVParseFormatException import com.github.doyaaaaaken.kotlincsv.util.Const import com.github.doyaaaaaken.kotlincsv.util.MalformedCSVException +import io.kotest.assertions.assertSoftly import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.WordSpec import io.kotest.matchers.shouldBe @@ -30,11 +31,13 @@ class CsvReaderTest : WordSpec({ skipEmptyLine = true } val reader = CsvReader(context) - reader.charset shouldBe Charsets.ISO_8859_1.name() - reader.quoteChar shouldBe '\'' - reader.delimiter shouldBe '\t' - reader.escapeChar shouldBe '"' - reader.skipEmptyLine shouldBe true + assertSoftly { + reader.charset shouldBe Charsets.ISO_8859_1.name() + reader.quoteChar shouldBe '\'' + reader.delimiter shouldBe '\t' + reader.escapeChar shouldBe '"' + reader.skipEmptyLine shouldBe true + } } } @@ -66,25 +69,26 @@ class CsvReaderTest : WordSpec({ val ex1 = shouldThrow { reader.readAll("a,\"\"failed") } - ex1.rowNum shouldBe 1 - ex1.colIndex shouldBe 4 - ex1.char shouldBe 'f' - val ex2 = shouldThrow { reader.readAll("a,b\nc,\"\"failed") } - - ex2.rowNum shouldBe 2 - ex2.colIndex shouldBe 4 - ex2.char shouldBe 'f' - val ex3 = shouldThrow { reader.readAll("a,\"b\nb\"\nc,\"\"failed") } - ex3.rowNum shouldBe 3 - ex3.colIndex shouldBe 4 - ex3.char shouldBe 'f' + assertSoftly { + ex1.rowNum shouldBe 1 + ex1.colIndex shouldBe 4 + ex1.char shouldBe 'f' + + ex2.rowNum shouldBe 2 + ex2.colIndex shouldBe 4 + ex2.char shouldBe 'f' + + ex3.rowNum shouldBe 3 + ex3.colIndex shouldBe 4 + ex3.char shouldBe 'f' + } } } @@ -170,9 +174,12 @@ class CsvReaderTest : WordSpec({ val ex = shouldThrow { csvReader().readAll(readTestDataFile("different-fields-num.csv")) } - ex.fieldNum shouldBe 3 - ex.fieldNumOnFailedRow shouldBe 2 - ex.csvRowNum shouldBe 2 + + assertSoftly { + ex.fieldNum shouldBe 3 + ex.fieldNumOnFailedRow shouldBe 2 + ex.csvRowNum shouldBe 2 + } } "Trim row when reading csv with greater num of fields on a subsequent row" { val expected = listOf(listOf("a", "b"), listOf("c", "d")) @@ -181,8 +188,10 @@ class CsvReaderTest : WordSpec({ excessFieldsRowBehaviour = ExcessFieldsRowBehaviour.TRIM }.readAll(readTestDataFile("different-fields-num2.csv")) - actual shouldBe expected - actual.size shouldBe 2 + assertSoftly { + actual shouldBe expected + actual.size shouldBe 2 + } } "it should be be possible to skip rows with both excess and insufficient fields" { val expected = listOf(listOf("a", "b")) @@ -192,8 +201,10 @@ class CsvReaderTest : WordSpec({ insufficientFieldsRowBehaviour = InsufficientFieldsRowBehaviour.IGNORE }.readAll(readTestDataFile("varying-column-lengths.csv")) - actual shouldBe expected - actual.size shouldBe 1 + assertSoftly { + actual shouldBe expected + actual.size shouldBe 1 + } } "it should be be possible to trim excess columns and skip insufficient row columns" { val expected = listOf(listOf("a", "b"), listOf("d","e")) @@ -203,8 +214,10 @@ class CsvReaderTest : WordSpec({ insufficientFieldsRowBehaviour = InsufficientFieldsRowBehaviour.IGNORE }.readAll(readTestDataFile("varying-column-lengths.csv")) - actual shouldBe expected - actual.size shouldBe 2 + assertSoftly { + actual shouldBe expected + actual.size shouldBe 2 + } } "If the excess fields behaviour is ERROR and the insufficient behaviour is IGNORE then an error should be thrown if there are excess columns" { val ex = shouldThrow { @@ -212,9 +225,12 @@ class CsvReaderTest : WordSpec({ insufficientFieldsRowBehaviour = InsufficientFieldsRowBehaviour.IGNORE }.readAll(readTestDataFile("varying-column-lengths.csv")) } - ex.fieldNum shouldBe 2 - ex.fieldNumOnFailedRow shouldBe 3 - ex.csvRowNum shouldBe 3 + + assertSoftly { + ex.fieldNum shouldBe 2 + ex.fieldNumOnFailedRow shouldBe 3 + ex.csvRowNum shouldBe 3 + } } "If the excess fields behaviour is IGNORE or TRIM and the insufficient behaviour is ERROR then an error should be thrown if there are columns with insufficient rows" { val ex1 = shouldThrow { @@ -222,18 +238,21 @@ class CsvReaderTest : WordSpec({ excessFieldsRowBehaviour = ExcessFieldsRowBehaviour.IGNORE }.readAll(readTestDataFile("varying-column-lengths.csv")) } - ex1.fieldNum shouldBe 2 - ex1.fieldNumOnFailedRow shouldBe 1 - ex1.csvRowNum shouldBe 2 - val ex2 = shouldThrow { csvReader { excessFieldsRowBehaviour = ExcessFieldsRowBehaviour.TRIM }.readAll(readTestDataFile("varying-column-lengths.csv")) } - ex2.fieldNum shouldBe 2 - ex2.fieldNumOnFailedRow shouldBe 1 - ex2.csvRowNum shouldBe 2 + + assertSoftly { + ex1.fieldNum shouldBe 2 + ex1.fieldNumOnFailedRow shouldBe 1 + ex1.csvRowNum shouldBe 2 + + ex2.fieldNum shouldBe 2 + ex2.fieldNumOnFailedRow shouldBe 1 + ex2.csvRowNum shouldBe 2 + } } "should not throw exception when reading csv with different fields num on each row with expected number of columns" { val expected = listOf(listOf("a", "b", "c")) @@ -241,17 +260,18 @@ class CsvReaderTest : WordSpec({ skipMissMatchedRow = true }.readAll(readTestDataFile("different-fields-num.csv")) - actual shouldBe expected - actual.size shouldBe 1 - val expected2 = listOf(listOf("a", "b")) val actual2 = csvReader { skipMissMatchedRow = true }.readAll(readTestDataFile("different-fields-num2.csv")) - actual2 shouldBe expected2 - actual2.size shouldBe 1 + assertSoftly { + actual shouldBe expected + actual.size shouldBe 1 + actual2 shouldBe expected2 + actual2.size shouldBe 1 + } } "should not throw exception when reading csv with header and different fields num on each row" { val expected = listOf( @@ -262,8 +282,10 @@ class CsvReaderTest : WordSpec({ skipMissMatchedRow = true }.readAllWithHeader(readTestDataFile("with-header-different-size-row.csv")) - actual.size shouldBe 2 - expected shouldBe actual + assertSoftly { + actual.size shouldBe 2 + expected shouldBe actual + } } } From e79952c901fa04c315340e9c194547c01ab9038b Mon Sep 17 00:00:00 2001 From: satokuuuuuun <51846075+satokuuuuuun@users.noreply.github.com> Date: Tue, 10 Jan 2023 11:47:39 +0900 Subject: [PATCH 2/8] fix(CsvReaderTest): style --- .../com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt index 45b554e..d13f646 100644 --- a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt +++ b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvReaderTest.kt @@ -243,7 +243,6 @@ class CsvReaderTest : WordSpec({ excessFieldsRowBehaviour = ExcessFieldsRowBehaviour.TRIM }.readAll(readTestDataFile("varying-column-lengths.csv")) } - assertSoftly { ex1.fieldNum shouldBe 2 ex1.fieldNumOnFailedRow shouldBe 1 From 098ed7aa296e35f56339e2ccef64c6a8bbc265ec Mon Sep 17 00:00:00 2001 From: satokuuuuuun <51846075+satokuuuuuun@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:25:52 +0900 Subject: [PATCH 3/8] refactor(BufferedLineReaderTest): change to use assertSoftly --- .../client/BufferedLineReaderTest.kt | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/BufferedLineReaderTest.kt b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/BufferedLineReaderTest.kt index 08efe27..018425b 100644 --- a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/BufferedLineReaderTest.kt +++ b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/BufferedLineReaderTest.kt @@ -1,5 +1,6 @@ package com.github.doyaaaaaken.kotlincsv.client +import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe @@ -8,61 +9,75 @@ class BufferedLineReaderTest : StringSpec({ val str = "a,b,c\nd,e,f" val br = str.byteInputStream().bufferedReader() val blr = BufferedLineReader(br) - blr.readLineWithTerminator() shouldBe "a,b,c\n" - blr.readLineWithTerminator() shouldBe "d,e,f" - blr.readLineWithTerminator() shouldBe null + assertSoftly { + blr.readLineWithTerminator() shouldBe "a,b,c\n" + blr.readLineWithTerminator() shouldBe "d,e,f" + blr.readLineWithTerminator() shouldBe null + } } "regard \\r\\n as line terminator" { val str = "a,b,c\r\nd,e,f" val br = str.byteInputStream().bufferedReader() val blr = BufferedLineReader(br) - blr.readLineWithTerminator() shouldBe "a,b,c\r\n" - blr.readLineWithTerminator() shouldBe "d,e,f" - blr.readLineWithTerminator() shouldBe null + assertSoftly { + blr.readLineWithTerminator() shouldBe "a,b,c\r\n" + blr.readLineWithTerminator() shouldBe "d,e,f" + blr.readLineWithTerminator() shouldBe null + } } "regard \\r as line terminator" { val str = "a,b,c\rd,e,f" val br = str.byteInputStream().bufferedReader() val blr = BufferedLineReader(br) - blr.readLineWithTerminator() shouldBe "a,b,c\r" - blr.readLineWithTerminator() shouldBe "d,e,f" - blr.readLineWithTerminator() shouldBe null + assertSoftly { + blr.readLineWithTerminator() shouldBe "a,b,c\r" + blr.readLineWithTerminator() shouldBe "d,e,f" + blr.readLineWithTerminator() shouldBe null + } } "regard \\u2028 as line terminator" { val str = "a,b,c\u2028d,e,f" val br = str.byteInputStream().bufferedReader() val blr = BufferedLineReader(br) - blr.readLineWithTerminator() shouldBe "a,b,c\u2028" - blr.readLineWithTerminator() shouldBe "d,e,f" - blr.readLineWithTerminator() shouldBe null + assertSoftly { + blr.readLineWithTerminator() shouldBe "a,b,c\u2028" + blr.readLineWithTerminator() shouldBe "d,e,f" + blr.readLineWithTerminator() shouldBe null + } } "regard \\u2029 as line terminator" { val str = "a,b,c\u2029d,e,f" val br = str.byteInputStream().bufferedReader() val blr = BufferedLineReader(br) - blr.readLineWithTerminator() shouldBe "a,b,c\u2029" - blr.readLineWithTerminator() shouldBe "d,e,f" - blr.readLineWithTerminator() shouldBe null + assertSoftly { + blr.readLineWithTerminator() shouldBe "a,b,c\u2029" + blr.readLineWithTerminator() shouldBe "d,e,f" + blr.readLineWithTerminator() shouldBe null + } } "regard \\u0085 as line terminator" { val str = "a,b,c\u0085d,e,f" val br = str.byteInputStream().bufferedReader() val blr = BufferedLineReader(br) - blr.readLineWithTerminator() shouldBe "a,b,c\u0085" - blr.readLineWithTerminator() shouldBe "d,e,f" - blr.readLineWithTerminator() shouldBe null + assertSoftly { + blr.readLineWithTerminator() shouldBe "a,b,c\u0085" + blr.readLineWithTerminator() shouldBe "d,e,f" + blr.readLineWithTerminator() shouldBe null + } } "deal with \\r at the end of file" { val str = "a,b,c\r" val br = str.byteInputStream().bufferedReader() val blr = BufferedLineReader(br) - blr.readLineWithTerminator() shouldBe "a,b,c\r" - blr.readLineWithTerminator() shouldBe null + assertSoftly { + blr.readLineWithTerminator() shouldBe "a,b,c\r" + blr.readLineWithTerminator() shouldBe null + } } }) From a682563ce350bd5145c8a427c224810706787844 Mon Sep 17 00:00:00 2001 From: satokuuuuuun <51846075+satokuuuuuun@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:32:08 +0900 Subject: [PATCH 4/8] refactor(CsvWriterTest): change to use assertSoftly --- .../doyaaaaaken/kotlincsv/client/CsvWriterTest.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvWriterTest.kt b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvWriterTest.kt index 049e0d0..1a50b49 100644 --- a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvWriterTest.kt +++ b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/CsvWriterTest.kt @@ -4,6 +4,7 @@ import com.github.doyaaaaaken.kotlincsv.dsl.context.CsvWriterContext import com.github.doyaaaaaken.kotlincsv.dsl.context.WriteQuoteMode import com.github.doyaaaaaken.kotlincsv.dsl.csvWriter import com.github.doyaaaaaken.kotlincsv.util.Const +import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.WordSpec import io.kotest.matchers.shouldBe import java.io.File @@ -37,12 +38,14 @@ class CsvWriterTest : WordSpec({ } } val writer = CsvWriter(context) - writer.charset shouldBe Charsets.ISO_8859_1.name() - writer.delimiter shouldBe '\t' - writer.nullCode shouldBe "NULL" - writer.lineTerminator shouldBe "\n" - writer.quote.char = '\'' - writer.quote.mode = WriteQuoteMode.ALL + assertSoftly { + writer.charset shouldBe Charsets.ISO_8859_1.name() + writer.delimiter shouldBe '\t' + writer.nullCode shouldBe "NULL" + writer.lineTerminator shouldBe "\n" + writer.quote.char = '\'' + writer.quote.mode = WriteQuoteMode.ALL + } } } From d9bb9cf617cf85a01dcd374b954c9db943b73ec1 Mon Sep 17 00:00:00 2001 From: satokuuuuuun <51846075+satokuuuuuun@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:34:54 +0900 Subject: [PATCH 5/8] refactor(StringReaderTest): change to use assertSoftly --- .../kotlincsv/client/StringReaderTest.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/StringReaderTest.kt b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/StringReaderTest.kt index 16210b6..93f55da 100644 --- a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/StringReaderTest.kt +++ b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/client/StringReaderTest.kt @@ -5,6 +5,7 @@ import com.github.doyaaaaaken.kotlincsv.util.CSVFieldNumDifferentException import com.github.doyaaaaaken.kotlincsv.util.CSVParseFormatException import com.github.doyaaaaaken.kotlincsv.util.MalformedCSVException import com.github.doyaaaaaken.kotlincsv.util.logger.LoggerNop +import io.kotest.assertions.assertSoftly import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.WordSpec import io.kotest.matchers.shouldBe @@ -37,25 +38,26 @@ class StringReaderTest : WordSpec({ val ex1 = shouldThrow { readAll("a,\"\"failed") } - ex1.rowNum shouldBe 1 - ex1.colIndex shouldBe 4 - ex1.char shouldBe 'f' - val ex2 = shouldThrow { readAll("a,b\nc,\"\"failed") } - - ex2.rowNum shouldBe 2 - ex2.colIndex shouldBe 4 - ex2.char shouldBe 'f' - val ex3 = shouldThrow { readAll("a,\"b\nb\"\nc,\"\"failed") } - ex3.rowNum shouldBe 3 - ex3.colIndex shouldBe 4 - ex3.char shouldBe 'f' + assertSoftly { + ex1.rowNum shouldBe 1 + ex1.colIndex shouldBe 4 + ex1.char shouldBe 'f' + + ex2.rowNum shouldBe 2 + ex2.colIndex shouldBe 4 + ex2.char shouldBe 'f' + + ex3.rowNum shouldBe 3 + ex3.colIndex shouldBe 4 + ex3.char shouldBe 'f' + } } } @@ -90,9 +92,11 @@ class StringReaderTest : WordSpec({ val ex = shouldThrow { readAll(readTestDataFile("different-fields-num.csv")) } - ex.fieldNum shouldBe 3 - ex.fieldNumOnFailedRow shouldBe 2 - ex.csvRowNum shouldBe 2 + assertSoftly { + ex.fieldNum shouldBe 3 + ex.fieldNumOnFailedRow shouldBe 2 + ex.csvRowNum shouldBe 2 + } } } From 3f5092d7fea5ed7115f79c68a5d2ee252b05e749 Mon Sep 17 00:00:00 2001 From: satokuuuuuun <51846075+satokuuuuuun@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:35:35 +0900 Subject: [PATCH 6/8] refactor(CsvReaderDslTest): change to use assertSoftly --- .../kotlincsv/dsl/CsvReaderDslTest.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/dsl/CsvReaderDslTest.kt b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/dsl/CsvReaderDslTest.kt index ed684fc..c99ae7e 100644 --- a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/dsl/CsvReaderDslTest.kt +++ b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/dsl/CsvReaderDslTest.kt @@ -3,6 +3,7 @@ package com.github.doyaaaaaken.kotlincsv.dsl import com.github.doyaaaaaken.kotlincsv.client.CsvReader import com.github.doyaaaaaken.kotlincsv.dsl.context.ExcessFieldsRowBehaviour import com.github.doyaaaaaken.kotlincsv.dsl.context.InsufficientFieldsRowBehaviour +import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeTypeOf @@ -26,12 +27,14 @@ class CsvReaderDslTest : StringSpec({ insufficientFieldsRowBehaviour = InsufficientFieldsRowBehaviour.IGNORE excessFieldsRowBehaviour = ExcessFieldsRowBehaviour.IGNORE } - reader.charset shouldBe Charsets.ISO_8859_1.name() - reader.quoteChar shouldBe '\'' - reader.delimiter shouldBe '\t' - reader.skipEmptyLine shouldBe true - reader.skipMissMatchedRow shouldBe true - reader.insufficientFieldsRowBehaviour shouldBe InsufficientFieldsRowBehaviour.IGNORE - reader.excessFieldsRowBehaviour shouldBe ExcessFieldsRowBehaviour.IGNORE + assertSoftly { + reader.charset shouldBe Charsets.ISO_8859_1.name() + reader.quoteChar shouldBe '\'' + reader.delimiter shouldBe '\t' + reader.skipEmptyLine shouldBe true + reader.skipMissMatchedRow shouldBe true + reader.insufficientFieldsRowBehaviour shouldBe InsufficientFieldsRowBehaviour.IGNORE + reader.excessFieldsRowBehaviour shouldBe ExcessFieldsRowBehaviour.IGNORE + } } }) From 904404c111ef65cbbad0aac4fce772e0d1f4b027 Mon Sep 17 00:00:00 2001 From: satokuuuuuun <51846075+satokuuuuuun@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:36:14 +0900 Subject: [PATCH 7/8] refactor(CsvWriterDslTest): change to use assertSoftly --- .../kotlincsv/dsl/CsvWriterDslTest.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/dsl/CsvWriterDslTest.kt b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/dsl/CsvWriterDslTest.kt index a76fe86..f998ba3 100644 --- a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/dsl/CsvWriterDslTest.kt +++ b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/dsl/CsvWriterDslTest.kt @@ -2,6 +2,7 @@ package com.github.doyaaaaaken.kotlincsv.dsl import com.github.doyaaaaaken.kotlincsv.client.CsvWriter import com.github.doyaaaaaken.kotlincsv.dsl.context.WriteQuoteMode +import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeTypeOf @@ -26,12 +27,14 @@ class CsvWriterDslTest : StringSpec({ mode = WriteQuoteMode.ALL } } - writer.charset shouldBe Charsets.ISO_8859_1.name() - writer.delimiter shouldBe '\t' - writer.nullCode shouldBe "NULL" - writer.lineTerminator shouldBe "\n" - writer.outputLastLineTerminator shouldBe false - writer.quote.char shouldBe '\'' - writer.quote.mode = WriteQuoteMode.ALL + assertSoftly { + writer.charset shouldBe Charsets.ISO_8859_1.name() + writer.delimiter shouldBe '\t' + writer.nullCode shouldBe "NULL" + writer.lineTerminator shouldBe "\n" + writer.outputLastLineTerminator shouldBe false + writer.quote.char shouldBe '\'' + writer.quote.mode = WriteQuoteMode.ALL + } } }) From 11209e516022305f887d9ebfd8b7cec4d20a1dbb Mon Sep 17 00:00:00 2001 From: satokuuuuuun <51846075+satokuuuuuun@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:36:54 +0900 Subject: [PATCH 8/8] refactor(CsvParserTest): change to use assertSoftly --- .../kotlincsv/parser/CsvParserTest.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/parser/CsvParserTest.kt b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/parser/CsvParserTest.kt index c23a7c6..4ea8f0e 100644 --- a/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/parser/CsvParserTest.kt +++ b/src/jvmTest/kotlin/com/github/doyaaaaaken/kotlincsv/parser/CsvParserTest.kt @@ -1,6 +1,7 @@ package com.github.doyaaaaaken.kotlincsv.parser import com.github.doyaaaaaken.kotlincsv.util.CSVParseFormatException +import io.kotest.assertions.assertSoftly import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.WordSpec import io.kotest.matchers.shouldBe @@ -59,17 +60,19 @@ class CsvParserTest : WordSpec({ val ex1 = shouldThrow { parser.parseRow("a,\"\"failed") } - ex1.rowNum shouldBe 1 - ex1.colIndex shouldBe 4 - ex1.char shouldBe 'f' - val ex2 = shouldThrow { parser.parseRow("a,\"\"failed", 2) } - ex2.rowNum shouldBe 2 - ex2.colIndex shouldBe 4 - ex2.char shouldBe 'f' + assertSoftly { + ex1.rowNum shouldBe 1 + ex1.colIndex shouldBe 4 + ex1.char shouldBe 'f' + + ex2.rowNum shouldBe 2 + ex2.colIndex shouldBe 4 + ex2.char shouldBe 'f' + } } } })