Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
LuciferYang authored and ppkarwasz committed Sep 12, 2024
1 parent 26ace09 commit fb32107
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ private HashMap<String, String> getTestParameters(int numParams) {
@Test
public void testCopyAndPut() {
UnmodifiableArrayBackedMap testMap = UnmodifiableArrayBackedMap.EMPTY_MAP;
testMap = testMap.copyAndPut("1", "value1");
assertTrue(testMap.containsKey("1"));
assertEquals(testMap.get("1"), "value1");
testMap = testMap.copyAndPut("6", "value6");
assertTrue(testMap.containsKey("6"));
assertEquals(testMap.get("6"), "value6");

testMap = testMap.copyAndPut("1", "another value");
assertTrue(testMap.containsKey("1"));
assertEquals(testMap.get("1"), "another value");
testMap = testMap.copyAndPut("6", "another value");
assertTrue(testMap.containsKey("6"));
assertEquals(testMap.get("6"), "another value");

HashMap<String, String> newValues = getTestParameters();
testMap = testMap.copyAndPutAll(newValues);
assertEquals(testMap.get("1"), "value1");
assertEquals(testMap.get("4"), "value4");
assertEquals(testMap.get("6"), "another value");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public UnmodifiableArrayBackedMap copyAndPutAll(Map<String, String> entriesToAdd
// copy the contents of the current map (if any)
if (numEntries > 0) {
System.arraycopy(backingArray, 0, newMap.backingArray, 0, numEntries * 2 + 1);
newMap.numEntries = numEntries;
}

for (Map.Entry<String, String> entry : entriesToAdd.entrySet()) {
Expand Down

0 comments on commit fb32107

Please sign in to comment.