From a165c357d186e7fc3f9afd92a40e08763f2fc30a Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Thu, 9 May 2019 09:28:48 +0100 Subject: [PATCH] Made failing test more generic, https://github.com/OpenHFT/Chronicle-Map/issues/169 --- .../map/ValueAlignmentRelocationTest.java | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/test/java/net/openhft/chronicle/map/ValueAlignmentRelocationTest.java b/src/test/java/net/openhft/chronicle/map/ValueAlignmentRelocationTest.java index a4ecdb740..f5f7f6fb5 100755 --- a/src/test/java/net/openhft/chronicle/map/ValueAlignmentRelocationTest.java +++ b/src/test/java/net/openhft/chronicle/map/ValueAlignmentRelocationTest.java @@ -105,26 +105,37 @@ public class ValueAlignmentRelocationTest { .entries(10); ChronicleMap map = persisted ? builder.createPersistedTo(file) : builder.create(); - byte[] _austi = "austi".getBytes(ISO_8859_1); - byte[] _12345678 = "12345678".getBytes(ISO_8859_1); - byte[] _h = "h".getBytes(ISO_8859_1); - byte[] _a = "a".getBytes(ISO_8859_1); - String expected = "1234567890123456"; - byte[] _1234567890123456 = expected.getBytes(ISO_8859_1); - byte[] _Hello = "Hello".getBytes(ISO_8859_1); - byte[] _world = "world".getBytes(ISO_8859_1); + for (int k = 1; k <= 16; k++) { + for (int i = 1; i < 10; i++) { + for (int j = i + 1; j <= i + 2; j++) { + map.clear(); - map.put(_austi, _12345678); - map.put(_h, _a); + byte[] _austi = "abcdefghijklmnopqrstuvwxyz".substring(0, k).getBytes(ISO_8859_1); + byte[] _shorter = "1234567890".substring(0, i).getBytes(ISO_8859_1); + byte[] _h = "h".getBytes(ISO_8859_1); + byte[] _a = "a".getBytes(ISO_8859_1); + String expected = "abcdefghijklmnopqrstuvwxyz".substring(0, j); + byte[] _longer = expected.getBytes(ISO_8859_1); + byte[] _Hello = "Hello".getBytes(ISO_8859_1); + byte[] _world = "world".getBytes(ISO_8859_1); - map.put(_austi, _1234567890123456); - String actual0 = toString(map.get(_austi)); - Assert.assertEquals(expected, actual0); + map.put(_austi, _shorter); + map.put(_h, _a); - map.put(_Hello, _world); - String actual = toString(map.get(_austi)); + map.put(_austi, _longer); + String actual0 = toString(map.get(_austi)); + Assert.assertEquals(expected, actual0); - Assert.assertEquals(expected, actual); + map.put(_Hello, _world); + String actual = toString(map.get(_austi)); + + if (expected.equals(actual)) + Assert.assertEquals(expected, actual); + else + System.out.println("k= " + k + ", i= " + i + ", j=" + j); + } + } + + } } - }