我想从随机序列中获取字符串组。我发现Randoms.takeFromValues提供了一个最适合的序列。但它没有按预期安静工作。我确信有些事我做得不对。这是一个测试代码,它在第二个断言时失败,因为list2的大小是2而不是3。
@Test
public void totallylazy_random_sequence_test() {
List<String> strings = list("string-1","string-2","string-3","string-4","string-5","string-6");
Sequence<String> selector = Randoms.takeFromValues(strings);
List<String> list1 = selector.take(3).toList();
List<String> list2 = selector.take(3).toList();
assertThat(list1.size(), is(3));
assertThat(list2.size(), is(3));
}