Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 1f9539b

Browse files
committed
Add Empty array tests
1 parent 768d86b commit 1f9539b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/ServiceStack.Text.Tests/BasicStringSerializerTests.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ public T Serialize<T>(T model)
391391
return fromJsonModel;
392392
}
393393

394-
#if !IOS
395394
public class TestClass
396395
{
397396
[Required]
@@ -624,6 +623,21 @@ public void Can_deserialize_int_with_leading_zeros()
624623
Assert.That("01".FromJson<long>(), Is.EqualTo(1));
625624
Assert.That("01".FromJson<ulong>(), Is.EqualTo(1));
626625
}
627-
#endif
626+
627+
public class EmptyCollections
628+
{
629+
public string[] Strings { get; set; }
630+
public int[] Ints { get; set; }
631+
}
632+
633+
[Test]
634+
public void Can_deserialize_empty_array()
635+
{
636+
Assert.That("[]".FromJson<string[]>(), Is.EquivalentTo(new string[0]));
637+
Assert.That("[]".FromJson<int[]>(), Is.EquivalentTo(new int[0]));
638+
639+
Assert.That("{\"Strings\":[]}".FromJson<EmptyCollections>().Strings, Is.EquivalentTo(new string[0]));
640+
Assert.That("{\"Ints\":[]}".FromJson<EmptyCollections>().Ints, Is.EquivalentTo(new int[0]));
641+
}
628642
}
629643
}

0 commit comments

Comments
 (0)