public void No_nesting() { var array = new[] { 0, 1, 2 }; var expected = new[] { 0, 1, 2 }; Assert.Equal(expected, FlattenArray.Flatten(array)); }
public void Number_6_level_nest_list_with_null_values() { var array = new object[] { 0, 2, new object[] { new object[] { 2, 3 }, 8, new object[] { new object[] { 100 } }, null, new object[] { new object[] { null } } }, -2 }; var expected = new[] { 0, 2, 2, 3, 8, 100, -2 }; Assert.Equal(expected, FlattenArray.Flatten(array)); }
public void Number_5_level_nesting() { var array = new object[] { 0, 2, new object[] { new object[] { 2, 3 }, 8, 100, 4, new object[] { new object[] { new object[] { 50 } } } }, -2 }; var expected = new[] { 0, 2, 2, 3, 8, 100, 4, 50, -2 }; Assert.Equal(expected, FlattenArray.Flatten(array)); }
public void Number_6_level_nesting() { var array = new object[] { 1, new object[] { 2, new object[] { new object[] { 3 } }, new object[] { 4, new object[] { new object[] { 5 } } }, 6, 7 }, 8 }; var expected = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; Assert.Equal(expected, FlattenArray.Flatten(array)); }
public void All_values_in_nested_list_are_null() { var array = new object[] { null, new object[] { new object[] { new object[] { null } } }, null, null, new object[] { new object[] { null, null }, null }, null }; Assert.Empty(FlattenArray.Flatten(array)); }
public void TestFlattenFunction_GivenListWithStrings_ReturnsFlatIntList() { var inputArrayList = new List <object> { "A", new List <object> { 1 }, new List <object> { new List <object> { "B", 2 }, 3 } }; var expectedOutput = new List <object> { "A", 1, "B", 2, 3 }; var testOutput = FlattenArray.Flatten(inputArrayList); testOutput.ShouldBe(expectedOutput); }
public void TestFlattenFunction_GivenMultipleNestedList_ReturnsFlatList() { var inputArrayList = new List <object> { 1, new List <object> { 2 }, new List <object> { new List <object> { 3, 4 }, 5 }, new List <object> { new List <object> { new List <object>() } }, new List <object> { new List <object> { new List <object> { 6 } } }, 7, 8, new List <object>() }; var expectedOutput = new List <object> { 1, 2, 3, 4, 5, 6, 7, 8 }; var testOutput = FlattenArray.Flatten(inputArrayList); testOutput.ShouldBe(expectedOutput); }
public void Flattens_array_with_just_integers_present() { var array = new object[] { 1, new object[] { 2, 3, 4, 5, 6, 7 }, 8 }; var expected = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; Assert.Equal(expected, FlattenArray.Flatten(array)); }
public void TestFlattenFunction_GivenEmptyList_ReturnsEmptyList() { var inputArrayList = new List <object> { }; var expectedOutput = new List <object> { }; var testOutput = FlattenArray.Flatten(inputArrayList); testOutput.ShouldBe(expectedOutput); }
public void TestFlattenFunction_GivenOneNestedList_ReturnsFlatList() { var inputArrayList = new List <object> { 1, new List <object> { 2, 3 } }; var expectedOutput = new List <object> { 1, 2, 3 }; var testOutput = FlattenArray.Flatten(inputArrayList); testOutput.ShouldBe(expectedOutput); }