@Test public void testEqualityAfterInsertDelete() { IValueFactory valueFactory = ValueFactory.getInstance(); int size = 50; ISetWriter writer1 = valueFactory.setWriter(); ISetWriter writer2 = valueFactory.setWriter(); for (int i = size; i > 0; i--) { writer1.insert(valueFactory.integer(i)); writer2.insert(valueFactory.integer(i)); } ISet testSet = writer1.done(); ISet testSetDuplicate = writer2.done(); // IValue VALUE_EXISTING = valueFactory.integer(size - 1); IValue VALUE_NOT_EXISTING = valueFactory.integer(size + 1); testSetDuplicate = testSet.insert(VALUE_NOT_EXISTING); testSetDuplicate = testSetDuplicate.delete(VALUE_NOT_EXISTING); boolean equals = testSet.equals(testSetDuplicate); assertTrue(equals); }
@Test public void testExtendedIteration() { IValueFactory valueFactory = ValueFactory.getInstance(); int size = 10_000; ISetWriter writer = valueFactory.setWriter(); Random random = new Random(); for (int i = size; i > 0; i--) { // writer.insert(valueFactory.integer(i)); // Random writer.insert(valueFactory.integer(random.nextInt())); } ISet testSet = writer.done(); int realSize = testSet.size(); int countedSize = 0; for (Object key : testSet) { countedSize++; } System.out.println(String.format("realSize[%d] == countedSize[%d]", realSize, countedSize)); assertTrue(realSize == countedSize); }