You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@SuppressWarnings("unchecked")
public void resizeTable(int newCapacity) {
Node<K, V>[] newTable = new Node[newCapacity];
for (int i = 0; i < table.length; i++){
int newIndex = calculateIndex(table[i], newCapacity);
newTable[newIndex] = table[i];
}
table = newTable;
}
Please, consider my test variation:
@Test
@Order(1)
@DisplayName("resizeTable creates a new array and put there all elements")
void resizeTable() {
for(int i = 10; i < 40; i++){
addToTable(String.valueOf(i), i % 7);
}
hashTable.resizeTable(64);
assertThat(getInternalTable(hashTable)).hasSize(64);
for(int i = 10; i < 40; i++){
assertTrue(checkKeyValueExists(String.valueOf(i), i % 7));
}
}
The text was updated successfully, but these errors were encountered:
obaibula
changed the title
2-2-7 resizeTable() method's test accept this corrupted code
2-2-7 resizeTable() method's test accepts this corrupted code
Mar 17, 2023
The accepted corrupted code:
Please, consider my test variation:
The text was updated successfully, but these errors were encountered: