public void testArrayTupleList() {
final Member genderFMember = xxx("[Gender].[F]");
final Member genderMMember = xxx("[Gender].[M]");
// empty list
final TupleList list0 = new ArrayTupleList(2);
assertTrue(list0.isEmpty());
assertEquals(0, list0.size());
assertEquals(list0, TupleCollections.emptyList(2));
TupleList list1 = new ArrayTupleList(2);
assertEquals(list0, list1);
final Member storeUsaMember = xxx("[Store].[USA]");
list1.add(Arrays.asList(storeUsaMember, genderFMember));
assertFalse(list1.isEmpty());
assertEquals(1, list1.size());
assertNotSame(list0, list1);
try {
list1.add(Arrays.asList(storeUsaMember));
fail("expected error");
} catch (IllegalArgumentException e) {
assertEquals("Tuple length does not match arity", e.getMessage());
}
try {
list1.addTuple(new Member[] {storeUsaMember});
fail("expected error");
} catch (IllegalArgumentException e) {
assertEquals("Tuple length does not match arity", e.getMessage());
}
try {
list1.add(
Arrays.asList(storeUsaMember, genderFMember, genderFMember));
fail("expected error");
} catch (IllegalArgumentException e) {
assertEquals("Tuple length does not match arity", e.getMessage());
}
try {
list1.addTuple(
new Member[]{storeUsaMember, genderFMember, genderFMember});
fail("expected error");
} catch (IllegalArgumentException e) {
assertEquals("Tuple length does not match arity", e.getMessage());
}
TupleList list2 = new ArrayTupleList(2);
list2.addTuple(new Member[]{storeUsaMember, genderFMember});
assertFalse(list2.isEmpty());
assertEquals(1, list2.size());
assertEquals(list1, list2);
list2.clear();
assertEquals(list0, list2);
assertEquals(list2, list0);
assertEquals("[]", list0.toString());
assertEquals("[[[Store].[USA], [Gender].[F]]]", list1.toString());
assertEquals("[]", list2.toString());
// For various lists, sublist returns the whole thing.
for (TupleList list : Arrays.asList(list0, list1, list2)) {
final TupleList sublist = list.subList(0, list.size());
assertNotNull(sublist);
assertNotNull(sublist.toString());
assertEquals(sublist.isEmpty(), list.isEmpty());
assertEquals(list, sublist);
assertNotSame(list, sublist);
}
// Null members OK (at least for TupleList).
list1.addTuple(storeUsaMember, null);
list1.add(Arrays.asList(storeUsaMember, null));
TupleList fm = new ArrayTupleList(2);
fm.addTuple(genderFMember, storeUsaMember);
fm.addTuple(genderMMember, storeUsaMember);
checkProject(fm);
}