From 88e5ef3e0106c2249d523b9fcbc510c4a4a33d74 Mon Sep 17 00:00:00 2001 From: Bruce Bowyer-Smyth Date: Mon, 31 Aug 2015 12:46:38 +1000 Subject: [PATCH] Tests for coreclr/pull/1460 --- src/System.Runtime/tests/System/String.cs | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/System.Runtime/tests/System/String.cs b/src/System.Runtime/tests/System/String.cs index 85a0e527a579..748b488d8066 100644 --- a/src/System.Runtime/tests/System/String.cs +++ b/src/System.Runtime/tests/System/String.cs @@ -756,7 +756,7 @@ public static void TestJoin() Assert.Throws(() => s = String.Join("@@", (Object[])null)); - // IEnumerable + // IEnumerable with IList optimization s = String.Join("|", new List() { }); Assert.Equal("", s); @@ -775,6 +775,36 @@ public static void TestJoin() s = String.Join("|", new List() { null, "Green", null }); Assert.Equal("|Green|", s); + // IEnumerable *without* IList optimization + Queue values = new Queue(); + s = String.Join("|", values); + Assert.Equal("", s); + + values.Enqueue(null); + s = String.Join("|", values); + Assert.Equal("", s); + + values.Clear(); + values.Enqueue("Red"); + s = String.Join("|", values); + Assert.Equal("Red", s); + + values.Clear(); + values.Enqueue("Red"); + values.Enqueue("Green"); + values.Enqueue("Blue"); + s = String.Join(null, values); + Assert.Equal("RedGreenBlue", s); + s = String.Join("|", values); + Assert.Equal("Red|Green|Blue", s); + + values.Clear(); + values.Enqueue(null); + values.Enqueue("Green"); + values.Enqueue(null); + s = String.Join("|", new List() { null, "Green", null }); + Assert.Equal("|Green|", s); + Assert.Throws(() => s = String.Join("|", (IEnumerable)null)); // IEnumerable