Commit | Line | Data |
---|---|---|
e06c9955 | 1 | /******************************************************************************* |
658401c8 | 2 | * Copyright (c) 2016 Ericsson |
e06c9955 MK |
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 | ||
658401c8 | 10 | package org.eclipse.tracecompass.analysis.timing.core.tests.segmentstore.statistics; |
e06c9955 | 11 | |
fb042960 | 12 | import java.util.Collection; |
e06c9955 | 13 | import java.util.Random; |
fb042960 | 14 | import java.util.stream.Collectors; |
e06c9955 MK |
15 | |
16 | import org.eclipse.jdt.annotation.NonNull; | |
fb042960 | 17 | import org.eclipse.tracecompass.analysis.timing.core.tests.statistics.AbstractStatisticsTest; |
660d4ed9 | 18 | import org.eclipse.tracecompass.segmentstore.core.BasicSegment; |
e06c9955 | 19 | import org.eclipse.tracecompass.segmentstore.core.ISegment; |
e06c9955 MK |
20 | |
21 | /** | |
fb042960 | 22 | * Test statistics for segment length |
e06c9955 MK |
23 | * |
24 | * @author Matthew Khouzam | |
e06c9955 | 25 | */ |
fb042960 | 26 | public class SegmentStoreStatisticsTest extends AbstractStatisticsTest<@NonNull ISegment> { |
e06c9955 | 27 | |
fb042960 | 28 | private final Random fRandom = new Random(10); |
ae2cf482 MK |
29 | |
30 | /** | |
fb042960 | 31 | * Constructor |
ae2cf482 | 32 | */ |
fb042960 GB |
33 | public SegmentStoreStatisticsTest() { |
34 | super(s -> s.getLength()); | |
ae2cf482 MK |
35 | } |
36 | ||
fb042960 GB |
37 | @Override |
38 | protected Collection<@NonNull ISegment> createElementsWithValues(Collection<@NonNull Long> longFixture) { | |
39 | return longFixture.stream() | |
40 | .map(l -> { | |
41 | long nextStart = fRandom.nextInt(10000000); | |
42 | long nextEnd = nextStart + l; | |
43 | // Check the boundaries, it is random after all, so if | |
44 | // there's an overflow, just take the max value as end time | |
45 | if (nextEnd < nextStart) { | |
46 | nextEnd = Long.MAX_VALUE; | |
47 | nextStart = nextEnd - l; | |
48 | } | |
49 | return new BasicSegment(nextStart, nextEnd); | |
50 | }) | |
51 | .collect(Collectors.toList()); | |
381e1541 | 52 | |
381e1541 MK |
53 | } |
54 | ||
fb042960 GB |
55 | @Override |
56 | public void testLimitDataset2() { | |
57 | /* ISegments do not support negative values */ | |
381e1541 MK |
58 | } |
59 | ||
fb042960 GB |
60 | @Override |
61 | public void testLargeDatasetNegative() { | |
62 | /* ISegments do not support negative values */ | |
381e1541 MK |
63 | } |
64 | ||
e06c9955 | 65 | } |