From 92d38b7f3746e3dd9ee98722d43778c4ecb0f6f4 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Wed, 8 Apr 2015 14:46:14 -0500 Subject: [PATCH] Add test for empty array decoding --- values_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/values_test.go b/values_test.go index 1938e13d..84af8fc6 100644 --- a/values_test.go +++ b/values_test.go @@ -223,6 +223,25 @@ func TestArrayDecoding(t *testing.T) { } } +func TestEmptyArrayDecoding(t *testing.T) { + t.Parallel() + + conn := mustConnect(t, *defaultConnConfig) + defer closeConn(t, conn) + + var val []string + + err := conn.QueryRow("select array[]::text[]").Scan(&val) + if err != nil { + t.Errorf(`error reading array: %v`, err) + } + if len(val) != 0 { + t.Errorf("Expected 0 values, got %d", len(val)) + } + + ensureConnValid(t, conn) +} + func TestNullXMismatch(t *testing.T) { t.Parallel()