Commit | Line | Data |
---|---|---|
664a3a81 LPD |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | *******************************************************************************/ | |
9 | ||
10 | package org.eclipse.tracecompass.segmentstore.core.tests; | |
11 | ||
12 | import static org.junit.Assert.assertEquals; | |
13 | import static org.junit.Assert.assertFalse; | |
14 | ||
131f8938 MK |
15 | import java.util.Arrays; |
16 | ||
664a3a81 LPD |
17 | import org.eclipse.jdt.annotation.NonNull; |
18 | import org.eclipse.tracecompass.internal.segmentstore.core.treemap.TreeMapStore; | |
19 | import org.eclipse.tracecompass.segmentstore.core.BasicSegment; | |
20 | import org.eclipse.tracecompass.segmentstore.core.ISegment; | |
21 | import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; | |
22 | import org.junit.Test; | |
23 | ||
24 | /** | |
25 | * Test specific behavior for a TreeMapStore segment store. | |
26 | * | |
27 | * @author France Lapointe Nguyen | |
28 | */ | |
29 | public class TreeMapStoreTest extends AbstractTestSegmentStore { | |
30 | ||
31 | @Override | |
32 | protected ISegmentStore<@NonNull ISegment> getSegmentStore() { | |
33 | return new TreeMapStore<>(); | |
34 | } | |
35 | ||
131f8938 MK |
36 | /** |
37 | * The TreeMapStore does not have a bulk loader, if it ever gets one, it should be tested here. | |
38 | */ | |
39 | @Override | |
40 | protected ISegmentStore<@NonNull ISegment> getSegmentStore(@NonNull ISegment @NonNull [] data) { | |
41 | TreeMapStore<@NonNull ISegment> treeMapStore = new TreeMapStore<>(); | |
42 | treeMapStore.addAll(Arrays.asList(data)); | |
43 | return treeMapStore; | |
44 | } | |
45 | ||
664a3a81 LPD |
46 | /** |
47 | * Try adding duplicate elements, they should be ignored | |
48 | */ | |
49 | @Test | |
50 | public void testNoDuplicateElements() { | |
51 | for (ISegment segment : SEGMENTS) { | |
52 | boolean ret = fSegmentStore.add(new BasicSegment(segment.getStart(), segment.getEnd())); | |
53 | assertFalse(ret); | |
54 | } | |
55 | assertEquals(SEGMENTS.size(), fSegmentStore.size()); | |
56 | } | |
57 | } |