Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ public final int iterateValues(final Consumer<? super E> procedure)
@Override
public final String toString()
{
if(this.size == 0)
{
return "{}";
}

final VarString vc = VarString.New().add('{');
for(Entry<E> entry : this.hashSlots)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.eclipse.serializer.collections;

/*-
* #%L
* Eclipse Serializer Integration Tests
* %%
* Copyright (C) 2023 - 2026 MicroStream Software
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class HashMapIdObjectTest
{
@Test
void toString_emptyMap()
{
// regression: threw StringIndexOutOfBoundsException
assertEquals("{}", HashMapIdObject.New().toString());
}

@Test
void toString_singleEntry()
{
final HashMapIdObject<String> map = HashMapIdObject.New();
map.add(1L, "a");
assertEquals("{1 -> a}", map.toString());
}

@Test
void toString_afterClear()
{
final HashMapIdObject<String> map = HashMapIdObject.New();
map.add(1L, "a");
map.clear();
assertEquals("{}", map.toString());
}
}
Loading