[impr-list-of-lists] The size of list of lists (#15002)

This commit is contained in:
Kai Yuan 2023-10-20 02:24:07 +02:00 committed by GitHub
parent 0530fb8bca
commit fdca014527
1 changed files with 12 additions and 1 deletions

View File

@ -71,4 +71,15 @@ public class ListOfListsUnitTest {
assertThat(listOfLists.get(2)).containsExactly("Slack", "Zoom", "Microsoft Teams", "Telegram");
printListOfLists(listOfLists);
}
}
@Test
void givenListOfLists_whenGettingSizeOfSubListsAndSizeOfElements_thenGetExpectedResults() throws URISyntaxException, IOException {
List<List<String>> listOfLists = getListOfListsFromCsv();
// size of inner lists
assertThat(listOfLists).hasSize(3);
// size of all elements in subLists
int totalElements = listOfLists.stream().mapToInt(List::size).sum();
assertThat(totalElements).isEqualTo(12);
}
}