From 761b00f9bcaaab43a6e7a386f4239fc62aefe39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 6 Oct 2024 12:45:38 +0200 Subject: [PATCH] Test Row.coalesce with collections of size zero and one. --- Tests/GRDBTests/RowCopiedFromStatementTests.swift | 8 +++++--- Tests/GRDBTests/RowFromDictionaryLiteralTests.swift | 8 +++++--- Tests/GRDBTests/RowFromDictionaryTests.swift | 8 +++++--- Tests/GRDBTests/RowFromStatementTests.swift | 8 +++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Tests/GRDBTests/RowCopiedFromStatementTests.swift b/Tests/GRDBTests/RowCopiedFromStatementTests.swift index 725618d64..e672d67d5 100644 --- a/Tests/GRDBTests/RowCopiedFromStatementTests.swift +++ b/Tests/GRDBTests/RowCopiedFromStatementTests.swift @@ -299,14 +299,16 @@ class RowCopiedFromStatementTests: RowTestCase { """) .map { row in [ + row.coalesce(Array()) as String?, + row.coalesce(["nickname"]) as String?, row.coalesce(["nickname", "name"]) as String?, row.coalesce([Column("nickname"), Column("name")]) as String?, ] } XCTAssertEqual(values, [ - ["Artie", "Artie"], - ["Jacob", "Jacob"], - [nil, nil], + [nil, "Artie", "Artie", "Artie"], + [nil, nil, "Jacob", "Jacob"], + [nil, nil, nil, nil], ]) } } diff --git a/Tests/GRDBTests/RowFromDictionaryLiteralTests.swift b/Tests/GRDBTests/RowFromDictionaryLiteralTests.swift index aabc43231..2554e6e20 100644 --- a/Tests/GRDBTests/RowFromDictionaryLiteralTests.swift +++ b/Tests/GRDBTests/RowFromDictionaryLiteralTests.swift @@ -241,14 +241,16 @@ class RowFromDictionaryLiteralTests : RowTestCase { ] let values = rows.map { row in [ + row.coalesce(Array()) as String?, + row.coalesce(["nickname"]) as String?, row.coalesce(["nickname", "name"]) as String?, row.coalesce([Column("nickname"), Column("name")]) as String?, ] } XCTAssertEqual(values, [ - ["Artie", "Artie"], - ["Jacob", "Jacob"], - [nil, nil], + [nil, "Artie", "Artie", "Artie"], + [nil, nil, "Jacob", "Jacob"], + [nil, nil, nil, nil], ]) } } diff --git a/Tests/GRDBTests/RowFromDictionaryTests.swift b/Tests/GRDBTests/RowFromDictionaryTests.swift index c429bbd21..5625295e4 100644 --- a/Tests/GRDBTests/RowFromDictionaryTests.swift +++ b/Tests/GRDBTests/RowFromDictionaryTests.swift @@ -233,14 +233,16 @@ class RowFromDictionaryTests : RowTestCase { ] let values = rows.map { row in [ + row.coalesce(Array()) as String?, + row.coalesce(["nickname"]) as String?, row.coalesce(["nickname", "name"]) as String?, row.coalesce([Column("nickname"), Column("name")]) as String?, ] } XCTAssertEqual(values, [ - ["Artie", "Artie"], - ["Jacob", "Jacob"], - [nil, nil], + [nil, "Artie", "Artie", "Artie"], + [nil, nil, "Jacob", "Jacob"], + [nil, nil, nil, nil], ]) } } diff --git a/Tests/GRDBTests/RowFromStatementTests.swift b/Tests/GRDBTests/RowFromStatementTests.swift index 62cc45529..85f17ff24 100644 --- a/Tests/GRDBTests/RowFromStatementTests.swift +++ b/Tests/GRDBTests/RowFromStatementTests.swift @@ -392,14 +392,16 @@ class RowFromStatementTests : RowTestCase { """) .map { row in [ + row.coalesce(Array()) as String?, + row.coalesce(["nickname"]) as String?, row.coalesce(["nickname", "name"]) as String?, row.coalesce([Column("nickname"), Column("name")]) as String?, ] }) XCTAssertEqual(values, [ - ["Artie", "Artie"], - ["Jacob", "Jacob"], - [nil, nil], + [nil, "Artie", "Artie", "Artie"], + [nil, nil, "Jacob", "Jacob"], + [nil, nil, nil, nil], ]) } }