From ec3bd9447e5b7e0b4716a8f91a89a63e1655228e Mon Sep 17 00:00:00 2001 From: leventov Date: Fri, 27 Nov 2015 19:00:42 +0300 Subject: [PATCH] #60 add a test --- .../openhft/chronicle/map/Issue60Test.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/test/java/net/openhft/chronicle/map/Issue60Test.java diff --git a/src/test/java/net/openhft/chronicle/map/Issue60Test.java b/src/test/java/net/openhft/chronicle/map/Issue60Test.java new file mode 100644 index 000000000..af71a4f06 --- /dev/null +++ b/src/test/java/net/openhft/chronicle/map/Issue60Test.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 higherfrequencytrading.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package net.openhft.chronicle.map; + +import org.junit.Assert; +import org.junit.Test; + +public class Issue60Test { + + @Test + public void issue60Test() { + int entries = 200; + int maxBloatFactor = 10; + int loop = 1000; + + try (ChronicleMap map = ChronicleMap + .of(String.class, String.class) + .entries(entries) + .averageKeySize(12) + .averageValueSize(12) + .maxBloatFactor(maxBloatFactor) + .create()) { + + System.out.println("begin test " + map.size()); + for (int i = 0; i < loop; i++) { + map.put("key" + i, "value" + i); + } + System.out.println("map size " + map.size()); + + int failedGet = 0; + for (int i = 0; i < loop; i++) { + String value = map.get("key" + i); + if (value == null) { + failedGet++; + } + } + Assert.assertEquals(0, failedGet); + System.out.println("failedGet " + failedGet); + System.out.println("map " + map); + } + } +}