From 7ff03ca6dd87e4abd4df4651da20eb6ee1c6d6f0 Mon Sep 17 00:00:00 2001 From: Giorgi Date: Fri, 10 Nov 2023 23:50:06 +0400 Subject: [PATCH] Add test for reading list of numeric values as other numeric list --- DuckDB.NET.Test/DuckDBDataReaderListTests.cs | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/DuckDB.NET.Test/DuckDBDataReaderListTests.cs b/DuckDB.NET.Test/DuckDBDataReaderListTests.cs index 404871ed..d436fe22 100644 --- a/DuckDB.NET.Test/DuckDBDataReaderListTests.cs +++ b/DuckDB.NET.Test/DuckDBDataReaderListTests.cs @@ -171,6 +171,49 @@ public void ReadListWithDapper() person.Mood.Should().Be(DuckDBDataReaderEnumTests.Mood.Happy); } + [Fact] + public void ReadListAsEveryNumericType() + { + Command.CommandText = "SELECT [1, 2, 3];"; + using var reader = Command.ExecuteReader(); + reader.Read(); + + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + + void TestReadValueAs() + { + var list = reader.GetFieldValue>(0); + list.Should().BeEquivalentTo(new List { 1, 2, 3 }); + } + } + + [Fact] + public void ReadListWithLargeValuesAsEveryNumericTypeThrowsException() + { + Command.CommandText = $"SELECT [{long.MaxValue - 1}, {long.MaxValue}];"; + using var reader = Command.ExecuteReader(); + reader.Read(); + + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + TestReadValueAs(); + + void TestReadValueAs() + { + reader.Invoking(dataReader => dataReader.GetFieldValue>(0)).Should().Throw(); + } + } + class Person { public List Ids { get; set; }