src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
UserHostPageFilter implements Filter { String securityContextJson(final User user) { final String userJson = ServerMarshalling.toJSON(user); return "{\"" + SecurityConstants.DICTIONARY_USER + "\": " + userJson + "}"; } @Override void init(FilterConfig filterConfig); @Override void destroy(); @Override void doFilter(Se... | @Test public void testSecurityContextJsonWhenAGroupHasAnApostrophe() throws Exception { final UserImpl user = new UserImpl("Mary", roles("admin"), groups("girls'", "programmer", "admin")); final String json = filter.securityContextJson(user); assertTrue(isValid(json)); }
@Test public void testSecurityContextJsonWhenAGr... |
JBossVfsDir implements Vfs.Dir { @Override public Iterable<Vfs.File> getFiles() { return new Iterable<Vfs.File>() { @Override public Iterator<Vfs.File> iterator() { final List<VirtualFile> toVisit = new ArrayList<VirtualFile>(virtualFile.getChildren()); return new AbstractIterator<Vfs.File>() { @Override protected Vfs.... | @Test public void testEmptyVfsDirListing() throws Exception { JBossVfsDir jbvd = new JBossVfsDir(getJBossVfsMountPoint().asDirectoryURL()); int count = 0; for (org.jboss.errai.reflections.vfs.Vfs.File reflectionsFile : jbvd.getFiles()) { System.out.println("Visiting virtual file " + reflectionsFile.getRelativePath()); ... |
EventDispatcher implements MessageCallback { static String getConversationalSessionId(Class<? extends Object> eventType) { final QueueSession queueSession = RpcContext.getQueueSession(); if (eventType.isAnnotationPresent(Conversational.class) && queueSession != null && queueSession.getSessionId() != null) { return queu... | @Test public void conversationalEventWithContext() { RpcContext.set(new MockMessage()); final String convSessionId = EventDispatcher.getConversationalSessionId(MyConversationalEvent.class); assertEquals("bearista", convSessionId); }
@Test public void conversationalEventWithoutContext() { final String convSessionId = Ev... |
Elemental2TagMapping { static Collection<String> getTags(final Class<?> elemental2ElementClass) { if (elemental2ElementClass == null || Element.class.equals(elemental2ElementClass)) { return Collections.emptyList(); } final Collection<String> tags = TAG_NAMES_BY_DOM_INTERFACE.get(elemental2ElementClass); if (tags.isEmp... | @Test public void testGetTags() { assertEquals("null should return no tag", emptyList(), getTags(null)); assertEquals("Object.class should not have any mapped tag name", emptyList(), getTags(Object.class)); assertEquals("String.class should not have any mapped tag name", emptyList(), getTags(String.class)); assertEqual... |
TemplatedCodeDecorator extends IOCDecoratorExtension<Templated> { @Override public void generateDecorator(final Decorable decorable, final FactoryController controller) { final MetaClass declaringClass = decorable.getDecorableDeclaringType(); final Templated anno = (Templated) decorable.getAnnotation(); final Class<?> ... | @Test public void nativeQuickHandlerWithNoEventTypeThrowsGenerationException() throws Exception { final MetaMethod handlerMethod = mock(MetaMethod.class); final MetaParameter eventParam = mock(MetaParameter.class); when(templatedClass.getMethodsAnnotatedWith(EventHandler.class)) .thenReturn(singletonList(handlerMethod)... |
TranslationServiceGenerator extends AbstractAsyncGenerator { public static String getLocaleFromBundlePath(final String bundlePath) { final Matcher matcher = LOCALE_IN_FILENAME_PATTERN.matcher(bundlePath); if (matcher != null && matcher.matches()) { final StringBuilder locale = new StringBuilder(); final String lang = m... | @Test public void testGetLocaleFromBundleFilename() { Assert.assertEquals(null, TranslationServiceGenerator.getLocaleFromBundlePath("myBundle.json")); Assert.assertEquals(null, TranslationServiceGenerator.getLocaleFromBundlePath("myBundle_en_US.other")); Assert.assertEquals("en_US", TranslationServiceGenerator.getLocal... |
TranslationServiceGenerator extends AbstractAsyncGenerator { @SuppressWarnings({ "rawtypes", "unchecked" }) protected static Set<String> recordBundleKeys(final Map<String, Set<String>> discoveredI18nMap, final String locale, final String bundlePath) { InputStream is = null; final Set<String> duplicates = new HashSet<>(... | @Test public void testRecordBundleKeys() { String jsonResourcePath = "org/jboss/errai/ui/test/i18n/client/I18nTemplateTest.json"; Map<String, Set<String>> result = new HashMap<String, Set<String>>(); TranslationServiceGenerator.recordBundleKeys(result, null, jsonResourcePath); Assert.assertEquals(1, result.keySet().siz... |
MetricGetter { @SafeVarargs public static final TagValue[][] getTagCombinations(Class<? extends TagValue>... tagValueClazzes) { int combinations = 1; for (Class<? extends TagValue> clazz : tagValueClazzes) { combinations *= clazz.getEnumConstants().length; } TagValue[][] result = new TagValue[combinations][]; List<List... | @Test public void testTagComboZero() { TagValue[][] expected = {{}}; assertEquals(MetricGetter.getTagCombinations(), expected); }
@Test public void testTagComboOne() { TagValue[][] expected = {{TimeoutTimedOut.TRUE}, {TimeoutTimedOut.FALSE}}; assertEquals(MetricGetter.getTagCombinations(TimeoutTimedOut.class), expected... |
Sleeper { public void sleepWhileConditionMet(BooleanSupplier condition, Time duration) throws InterruptedException { long timeoutMs = duration.valueAsMillis(); long sleepingPeriodMs = getSleepingPeriodMs(timeoutMs); long timeWaited = 0; while (condition.getAsBoolean() && timeWaited < timeoutMs) { sleepMs(sleepingPeriod... | @Test public void sleepWhileConditionMet_conditionDoesNotChangeBeforeTime_sleepsAllottedTime() throws Exception { final long SLEEP_TIME_MS = 100; Sleeper sleeper = new Sleeper(); long start = System.nanoTime(); sleeper.sleepWhileConditionMet(Suppliers.of(true), Time.milliseconds(SLEEP_TIME_MS)); long passed = (long) ((... |
RequirementsControl { public Optional<Action> getActionOnRequirement(Requirement requirement) { return Optional.ofNullable(mActionsOnRequirement.get(requirement)); } RequirementsControl(Logger logger, Map<Requirement, Action> actionsOnRequirement, Map<Subsystem, Action> defaultActionsOnSubsystems); RequirementsControl... | @Test public void getActionOnSubsystem_subsystemHasNoAction_returnsEmpty() throws Exception { Subsystem subsystem = mock(Subsystem.class); Optional<Action> optionalAction = mRequirementsControl.getActionOnRequirement(subsystem); assertFalse(optionalAction.isPresent()); }
@Test public void getActionOnSubsystem_forSubsys... |
RequirementsControl { public void setDefaultActionOnSubsystem(Subsystem subsystem, Action action) { if (!action.getConfiguration().getRequirements().contains(subsystem)) { action.configure() .requires(subsystem) .save(); } mDefaultActionsOnSubsystems.put(subsystem, action); } RequirementsControl(Logger logger, Map<Requ... | @Test public void setDefaultActionOnSubsystem_defaultAlreadyExists_replacesAction() throws Exception { Subsystem subsystem = mock(Subsystem.class); Action action = mock(Action.class); mDefaultActionsOnSubsystems.put(subsystem, action); Action newAction = ActionsMock.actionMocker() .mockWithRequirements(Collections.sing... |
RequirementsControl { public Map<Subsystem, Action> getDefaultActionsToStart() { Map<Subsystem, Action> actionsToStart = new HashMap<>(); for (Map.Entry<Subsystem, Action> entry : mDefaultActionsOnSubsystems.entrySet()) { if (mActionsOnRequirement.containsKey(entry.getKey())) { continue; } actionsToStart.put(entry.getK... | @Test public void getDefaultActionsToStart_noActionsAreRunning_returnsAll() throws Exception { Map<Subsystem, Action> defaultActions = new HashMap<>(); defaultActions.put(mock(Subsystem.class), mock(Action.class)); defaultActions.put(mock(Subsystem.class), mock(Action.class)); mDefaultActionsOnSubsystems.putAll(default... |
ActionControl { public void startAction(Action action) { if (mRunningActions.containsKey(action)) { throw new IllegalStateException("action already running"); } if (mNextRunActions.contains(action)) { throw new IllegalStateException("action already scheduled to run"); } mNextRunActions.add(action); } ActionControl(Cloc... | @Test public void startAction_actionNotRunning_addsToRunning() throws Exception { Action action = mock(Action.class); mActionControl.startAction(action); assertThat(mNextRunActions, IsIterableContaining.hasItem(action)); }
@Test public void startAction_actionRunning_throwsIllegalStateException() throws Exception { asse... |
ActionControl { public void cancelAction(Action action) { ActionContext context = mRunningActions.get(action); if (context != null) { context.cancelAction(); } else { throw new IllegalStateException("action is not running"); } } ActionControl(Clock clock, RequirementsControl requirementsControl, Map<Action, ActionConte... | @Test public void cancelAction_actionRunning_cancels() throws Exception { Action action = mock(Action.class); ActionContext context = mock(ActionContext.class); mRunningActions.put(action, context); mActionControl.cancelAction(action); verify(context, times(1)).cancelAction(); }
@Test public void cancelAction_actionNot... |
Time implements Comparable<Time> { public boolean before(Time other) { return lessThan(other); } Time(long value, TimeUnit unit); static Time of(long value, TimeUnit unit); static Time milliseconds(long valueMs); static Time seconds(long valueSeconds); static Time seconds(double valueSeconds); static Time minutes(long ... | @Test public void before_thisIsNotValidOtherIsNotValid_returnsFalse() throws Exception { final Time THIS = Time.INVALID; final Time OTHER = Time.INVALID; assertFalse(THIS.before(OTHER)); } |
ActionControl { public boolean isActionRunning(Action action) { return mRunningActions.containsKey(action); } ActionControl(Clock clock, RequirementsControl requirementsControl, Map<Action, ActionContext> runningActions, Collection<Action> nextRunActions); ActionControl(Clock clock, RequirementsControl requirementsCon... | @Test public void isRunning_actionNotRunning_returnsFalse() throws Exception { Action action = mock(Action.class); Assertions.assertFalse(mActionControl.isActionRunning(action)); }
@Test public void isRunning_actionRunning_returnsTrue() throws Exception { Action action = mock(Action.class); mRunningActions.put(action, ... |
ActionControl { public void updateActionsForNextRun(Iterable<Action> actionsToRemove) { actionsToRemove.forEach(this::internalRemove); } ActionControl(Clock clock, RequirementsControl requirementsControl, Map<Action, ActionContext> runningActions, Collection<Action> nextRunActions); ActionControl(Clock clock, Requirem... | @Test public void updateActionsForNextRun_withActionsToRemove_runMarkedFinished() throws Exception { Map<Action, ActionContext> actions = new HashMap<>(); actions.put(mock(Action.class), mock(ActionContext.class)); actions.put(mock(Action.class), mock(ActionContext.class)); mRunningActions.putAll(actions); mActionContr... |
ActionControl { public void startNewActions() { mNextRunActions.forEach(this::internalAdd); mNextRunActions.clear(); } ActionControl(Clock clock, RequirementsControl requirementsControl, Map<Action, ActionContext> runningActions, Collection<Action> nextRunActions); ActionControl(Clock clock, RequirementsControl requir... | @Test public void startNewActions_withActionsToStart_startsActions() throws Exception { Collection<Action> actions = Arrays.asList( ActionsMock.actionMocker().build(), ActionsMock.actionMocker().build() ); mNextRunActions.addAll(actions); mActionControl.startNewActions(); MatcherAssert.assertThat(mRunningActions.keySet... |
ActionControl { public void cancelAllActions() { mNextRunActions.clear(); mRunningActions.forEach(this::onInternalRemove); mRunningActions.clear(); } ActionControl(Clock clock, RequirementsControl requirementsControl, Map<Action, ActionContext> runningActions, Collection<Action> nextRunActions); ActionControl(Clock cl... | @Test public void stopAllActions_withRunningActions_runMarkedFinished() throws Exception { Map<Action, ActionContext> actions = new HashMap<>(); actions.put(mock(Action.class), mock(ActionContext.class)); actions.put(mock(Action.class), mock(ActionContext.class)); mRunningActions.putAll(actions); mActionControl.cancelA... |
SchedulerIteration { public void run(SchedulerMode mode) { mActionsToRemove.clear(); startNewActions(); runActions(mode); startDefaultSubsystemActions(mode); readyForNextRun(); } SchedulerIteration(ActionControl actionControl, RequirementsControl requirementsControl, Logger logger); void run(SchedulerMode mode); } | @Test public void run_withActions_runsActions() throws Exception { ActionContext actionContext = ActionsMock.contextMocker() .runFinished(false) .build(); mActionControlMock.runningAction(actionContext); mSchedulerIteration.run(SchedulerModeMock.mockNotDisabledMode()); verify(actionContext, times(1)).run(); }
@Test pub... |
Time implements Comparable<Time> { public boolean after(Time other) { return largerThan(other); } Time(long value, TimeUnit unit); static Time of(long value, TimeUnit unit); static Time milliseconds(long valueMs); static Time seconds(long valueSeconds); static Time seconds(double valueSeconds); static Time minutes(long... | @Test public void after_thisIsNotValidOtherIsNotValid_returnsFalse() throws Exception { final Time THIS = Time.INVALID; final Time OTHER = Time.INVALID; assertFalse(THIS.after(OTHER)); } |
SequentialActionGroup extends ActionGroupBase { @Override public final void execute() { if (mCurrentAction == null) { startNextAction(); } handleCurrentAction(); } SequentialActionGroup(Scheduler scheduler, Clock clock,
Collection<Action> actions, Queue<ActionContext> actionQueue); Sequential... | @Test public void execute_noActionCurrentlyRunning_startsNextAction() throws Exception { List<Action> actions = Collections.singletonList( ActionsMock.actionMocker().build() ); ActionContext context = mock(ActionContext.class); Deque<ActionContext> contexts = new ArrayDeque<>(Collections.singleton( context )); Sequenti... |
PeriodicAction extends ActionBase { @Override public void execute() { if (!mNextRun.isValid() || mClock.currentTime().largerThanOrEquals(mNextRun)) { mRunnable.run(); mNextRun = mClock.currentTime().add(mPeriod); } } PeriodicAction(Clock clock, Runnable runnable, Time period, Time nextRun); PeriodicAction(Clock clock,... | @Test public void execute_notFirstRunTimeHasElapsed_runsRunnable() throws Exception { Runnable runnable = mock(Runnable.class); Time nextRun = Time.seconds(1); when(mClock.currentTime()).thenReturn(nextRun); PeriodicAction action = new PeriodicAction(mClock, runnable, Time.seconds(1), nextRun); action.execute(); verify... |
DoubleBuffer { public void write(T value) { int index = mReadIndex.get(); mArray.set(index, value); mReadIndex.updateAndGet(mReadIndexUpdater); } DoubleBuffer(AtomicReferenceArray<T> array, AtomicInteger readIndex); DoubleBuffer(); T read(); void write(T value); } | @Test public void write_ofObject_writesObjectToWriteIndex() throws Exception { final Object VALUE = new Object(); AtomicReferenceArray<Object> innerArray = new AtomicReferenceArray<>(2); DoubleBuffer<Object> doubleBuffer = new DoubleBuffer<>(innerArray, new AtomicInteger(0)); doubleBuffer.write(VALUE); assertEquals(VAL... |
Time implements Comparable<Time> { public boolean equals(Time other) { return CompareResult.EQUAL_TO.is(compareTo(other)); } Time(long value, TimeUnit unit); static Time of(long value, TimeUnit unit); static Time milliseconds(long valueMs); static Time seconds(long valueSeconds); static Time seconds(double valueSeconds... | @Test public void equals_thisIsNotValidOtherIsNotValid_returnsTrue() throws Exception { final Time THIS = Time.INVALID; final Time OTHER = Time.INVALID; assertTrue(THIS.equals(OTHER)); } |
DoubleBuffer { public T read() { T value = mArray.get(mReadIndex.get()); if (value == null) { throw new NoSuchElementException("nothing to read"); } return value; } DoubleBuffer(AtomicReferenceArray<T> array, AtomicInteger readIndex); DoubleBuffer(); T read(); void write(T value); } | @Test public void read_initialValues_throwsNoSuchElementException() throws Exception { assertThrows(NoSuchElementException.class, ()->{ AtomicReferenceArray<Object> innerArray = new AtomicReferenceArray<>(2); DoubleBuffer<Object> doubleBuffer = new DoubleBuffer<>(innerArray, new AtomicInteger(0)); doubleBuffer.read(); ... |
SyncPipeJunction implements Pipeline<T> { @Override public void process(T input) throws VisionException { for (Pipeline<? super T> pipeline : mPipelines) { pipeline.process(input); } } SyncPipeJunction(Collection<Pipeline<? super T>> pipelines); @SafeVarargs SyncPipeJunction(Pipeline<? super T>... pipelines); @Overrid... | @Test public void process_forInput_passesToAllPipes() throws Exception { final Pipeline[] PIPELINES = { mock(Pipeline.class), mock(Pipeline.class), mock(Pipeline.class) }; final Object INPUT = new Object(); SyncPipeJunction<Object> syncPipeJunction = new SyncPipeJunction<>(PIPELINES); syncPipeJunction.process(INPUT); f... |
SyncPipeJunction implements Pipeline<T> { @Override public Pipeline<T> divergeTo(Pipeline<? super T> pipeline) { mPipelines.add(pipeline); return this; } SyncPipeJunction(Collection<Pipeline<? super T>> pipelines); @SafeVarargs SyncPipeJunction(Pipeline<? super T>... pipelines); @Override void process(T input); @Overr... | @Test public void divergeTo_forNewPipeline_addsPipelineToJunctionWithPreviousOnes() throws Exception { final Pipeline[] PIPELINES = { mock(Pipeline.class), mock(Pipeline.class), mock(Pipeline.class) }; final Pipeline<? super Object> NEW_PIPELINE = mock(Pipeline.class); Collection<Pipeline> pipelines = new ArrayList<>(A... |
ProcessorChain implements Processor { @SuppressWarnings("unchecked") @Override public Object process(Object input) throws VisionException { Object out = input; for (Processor processor : mProcessors) { out = processor.process(out); } return out; } ProcessorChain(Collection<Processor> processors); ProcessorChain(Proce... | @Test public void process_withTwoProcessors_processesInAndPipesToOut() throws Exception { final Object INPUT = new Object(); final Object OUTPUT_IN = new Object(); final Processor<Object, Object> PROCESSOR_IN = mockProcessorWithInputOutput(INPUT, OUTPUT_IN); final Processor<Object, Object> PROCESSOR_OUT = mock(Processo... |
ProcessorPair implements Processor<T, R2> { @Override public R2 process(T input) throws VisionException { R out = mIn.process(input); return mOut.process(out); } ProcessorPair(Processor<T, R> in, Processor<? super R, R2> out); @Override R2 process(T input); } | @Test public void process_forInput_processesInAndPipesToOut() throws Exception { final Object INPUT = new Object(); final Object OUTPUT_IN = new Object(); final Processor<Object, Object> PROCESSOR_IN = mock(Processor.class); when(PROCESSOR_IN.process(eq(INPUT))).thenReturn(OUTPUT_IN); final Processor<Object, Object> PR... |
RequirementsControl { public void updateRequirementsNoCurrentAction(Action action) { for (Requirement requirement : action.getConfiguration().getRequirements()) { mActionsOnRequirement.remove(requirement); } } RequirementsControl(Logger logger, Map<Requirement, Action> actionsOnRequirement, Map<Subsystem, Action> defau... | @Test public void updateRequirementsNoCurrentAction_actionUsesAllSubsystems_removesAllSubsystems() throws Exception { Collection<Subsystem> subsystems = Arrays.asList( mock(Subsystem.class), mock(Subsystem.class), mock(Subsystem.class)); Action action = ActionsMock.actionMocker() .mockWithRequirements(subsystems) .buil... |
InProcessorJunction implements Processor<T, R> { @Override public R process(T input) throws VisionException { mPipeline.process(input); return mProcessor.process(input); } InProcessorJunction(Processor<T, R> processor, Pipeline<? super T> pipeline); @Override R process(T input); @Override Processor<T, R> divergeIn(Pipe... | @Test public void process_forInput_processesAndPipesInputToPipeline() throws Exception { final Object INPUT = new Object(); final Processor<Object, Object> PROCESSOR = mock(Processor.class); final Pipeline<Object> PIPELINE = mock(Pipeline.class); InProcessorJunction<Object, Object> inProcessorJunction = new InProcessor... |
OutProcessorJunction implements Processor<T, R> { @Override public R process(T input) throws VisionException { R out = mProcessor.process(input); mPipeline.process(out); return out; } OutProcessorJunction(Processor<T, R> processor, Pipeline<? super R> pipeline); @Override R process(T input); @Override Processor<T, R> d... | @Test public void process_forInput_processesAndPipesOutputToPipeline() throws Exception { final Object INPUT = new Object(); final Object OUTPUT = new Object(); final Processor<Object, Object> PROCESSOR = mock(Processor.class); when(PROCESSOR.process(eq(INPUT))).thenReturn(OUTPUT); final Pipeline<Object> PIPELINE = moc... |
RequirementsControl { public void updateRequirementsWithNewRunningAction(Action action) { for (Requirement requirement : action.getConfiguration().getRequirements()) { if (mActionsOnRequirement.containsKey(requirement)) { Action currentAction = mActionsOnRequirement.get(requirement); currentAction.cancel(); mLogger.war... | @Test public void updateRequirementsWithNewRunningAction_actionWithSomeRequirements_addsRequirementsToMap() throws Exception { Collection<Subsystem> otherSubsystems = Arrays.asList( mock(Subsystem.class), mock(Subsystem.class), mock(Subsystem.class)); Collection<Subsystem> usedSubsystems = Arrays.asList( mock(Subsystem... |
SPARQLBasedTrivialInconsistencyFinder extends AbstractTrivialInconsistencyFinder { @Override public void run(boolean resume) { for(AbstractTrivialInconsistencyFinder checker : incFinders){ if(!(checker instanceof InverseFunctionalityBasedInconsistencyFinder) || isApplyUniqueNameAssumption()){ try { checker.run(resume);... | @Test public void testRun() { incFinder.run(); }
@Test public void testGetExplanations() { incFinder.run(); Set<Explanation<OWLAxiom>> explanations = incFinder.getExplanations(); for (Explanation<OWLAxiom> explanation : explanations) { System.out.println(explanation.getAxioms()); } } |
GenerateTradeData { public List<Trade> createRandomData(int number) throws Exception { return null; } Trade createTradeData(int number, List<Party> partyList,
List<Instrument> instrumentList); List<Trade> createRandomData(int number); } | @Test public void testGenerateRandomInstrument() throws Exception { GenerateRandomInstruments ranIns = new GenerateRandomInstruments(); assert (ranIns.createRandomData(50).size() == 50); }
@Test public void testGeneratePartyData() throws Exception { GenerateRandomParty ransPty = new GenerateRandomParty(); assert (ransP... |
SegmentedLog { public void truncateSuffix(long newEndIndex) { if (newEndIndex >= getLastLogIndex()) { return; } LOG.info("Truncating log from old end index {} to new end index {}", getLastLogIndex(), newEndIndex); while (!startLogIndexSegmentMap.isEmpty()) { Segment segment = startLogIndexSegmentMap.lastEntry().getValu... | @Test public void testTruncateSuffix() throws IOException { String raftDataDir = "./data"; SegmentedLog segmentedLog = new SegmentedLog(raftDataDir, 32); Assert.assertTrue(segmentedLog.getFirstLogIndex() == 1); List<RaftProto.LogEntry> entries = new ArrayList<>(); for (int i = 1; i < 10; i++) { RaftProto.LogEntry entry... |
Snapshot { public TreeMap<String, SnapshotDataFile> openSnapshotDataFiles() { TreeMap<String, SnapshotDataFile> snapshotDataFileMap = new TreeMap<>(); String snapshotDataDir = snapshotDir + File.separator + "data"; try { Path snapshotDataPath = FileSystems.getDefault().getPath(snapshotDataDir); snapshotDataPath = snaps... | @Test public void testReadSnapshotDataFiles() throws IOException { String raftDataDir = "./data"; File file = new File("./data/message"); file.mkdirs(); File file1 = new File("./data/message/queue1.txt"); file1.createNewFile(); File file2 = new File("./data/message/queue2.txt"); file2.createNewFile(); File snapshotFile... |
MergedItem { static MergedItem newInjectedRow(int type) { return new MergedItem(type, type, true); } private MergedItem(int type, long id, boolean injected); @Override boolean equals(Object o); } | @Test public void testNewInjectedRowBuilder() { MergedItem mergedItem = MergedItem.newInjectedRow(1); assertThat(mergedItem.injected, is(true)); assertThat(mergedItem.type, is(1)); assertThat(mergedItem.id, is(1L)); } |
ItemsMerger { List<MergedItem> mergeItems() { MergeStrategy mergeStrategy = getMergeStrategy(); return mergeStrategy.mergeItems(); } ItemsMerger(ItemsDataProvider itemsDataProvider, MergeOptionsProvider mergeOptionsProvider); } | @Test public void hidesInjectedItemsOnEmptyChildItemsIfNotAllowed() { Item Injected_0_1 = createInjectedItem(0, 0); Item Injected_5_1 = createInjectedItem(5, 1); ItemsMerger itemsMerger = new ItemsMerger( createItemsDataProvider(Arrays.asList(Injected_0_1, Injected_5_1), Collections.<Item>emptyList()), createMergeOptio... |
MergedItem { static MergedItem newRow(int type, long id) { return new MergedItem(type, id, false); } private MergedItem(int type, long id, boolean injected); @Override boolean equals(Object o); } | @Test public void testNewRowBuilder() { MergedItem mergedItem = MergedItem.newRow(1, 2L); assertThat(mergedItem.injected, is(false)); assertThat(mergedItem.type, is(1)); assertThat(mergedItem.id, is(2L)); }
@Test public void testMergedItemEqual() { MergedItem mergedItem1 = MergedItem.newRow(1, 2L); MergedItem mergedIte... |
VectorCalculator { int[] calculateFromChildItemPositionTranslationVector() { int maxInjectedItemPosition = getMaxInjectedItemPosition(); if (maxInjectedItemPosition != NO_POSITION) { int vectorSize = maxInjectedItemPosition - dataProvider.getInjectedItemCount() + 2; int[] vector = new int[vectorSize]; int accumulator =... | @Test public void calculateFromChildItemPositionTranslationVector() throws Exception { testFromChildVectorValue(Collections.<Integer>emptyList(), new int[]{ 0 }); testFromChildVectorValue(new ArrayList<Integer>() {{ add(0); }}, new int[]{ 1 }); testFromChildVectorValue(new ArrayList<Integer>() {{ add(1); add(2); add(3)... |
VectorCalculator { int[] calculateNumberOfInjectedItemsUpToPosition() { int maxInjectedItemPosition = getMaxInjectedItemPosition(); if (maxInjectedItemPosition != NO_POSITION) { int[] vector = new int[maxInjectedItemPosition + 1]; int previousValue = 0; for (int i = 0; i < vector.length; i++) { vector[i] = previousValu... | @Test public void calculateNumberOfInjectedItemsUpToPosition() throws Exception { testNumberOfInjectedItemsVectorValue(Collections.<Integer>emptyList(), new int[]{ 0 }); testNumberOfInjectedItemsVectorValue(new ArrayList<Integer>() {{ add(0); }}, new int[]{ 1 }); testNumberOfInjectedItemsVectorValue(new ArrayList<Integ... |
MergedListDiffer extends DiffUtil.Callback { void updateData(List<MergedItem> oldList, List<MergedItem> newList) { this.oldList = oldList; this.newList = newList; } @Override int getOldListSize(); @Override int getNewListSize(); @Override boolean areItemsTheSame(int oldItemPosition, int newItemPosition); @Override boo... | @Test public void returnsCorrectSizeOfOldList() { MergedListDiffer mergedListDiffer = new MergedListDiffer(); mergedListDiffer.updateData(new ArrayList<MergedItem>() {{ add(MergedItem.newInjectedRow(2)); add(MergedItem.newInjectedRow(3)); }}, Collections.<MergedItem>emptyList()); } |
MergedListDiffer extends DiffUtil.Callback { @Override public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) { MergedItem oldRow = oldList.get(oldItemPosition); MergedItem newRow = newList.get(newItemPosition); return oldRow.type == newRow.type && oldRow.id == newRow.id; } @Override int getOldListSi... | @Test public void testAreItemsTheSame() { MergedListDiffer mergedListDiffer = new MergedListDiffer(); mergedListDiffer.updateData(new ArrayList<MergedItem>() {{ add(MergedItem.newInjectedRow(2)); add(MergedItem.newInjectedRow(3)); }}, new ArrayList<MergedItem>() {{ add(MergedItem.newInjectedRow(2)); add(MergedItem.newI... |
MergedListDiffer extends DiffUtil.Callback { @Override public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) { return true; } @Override int getOldListSize(); @Override int getNewListSize(); @Override boolean areItemsTheSame(int oldItemPosition, int newItemPosition); @Override boolean areContentsT... | @Test public void areContentsTheSameAlwaysReturnsTrue() { MergedListDiffer mergedListDiffer = new MergedListDiffer(); assertThat(mergedListDiffer.areContentsTheSame(1, 1), is(true)); } |
Parameter implements Cloneable { public Parameter(String name) { setNameAndParent(name,null); } Parameter(String name); Parameter(String name, boolean value); Parameter(String name, int value); Parameter(String name, long value); Parameter(String name, float value); Parameter(String name, double value); Parameter... | @Test public void testParameter() { Parameter par = new Parameter("fo<o","Hello"); assertEquals("Hello",par.getString()); par.setString("true"); assertTrue(par.getBoolean()); par.setString("3141"); assertEquals(3141,par.getInt()); par.setString("3141.0"); assertEquals(3141.0f,par.getFloat()); par.setString("3.141"); as... |
DMatrixSvd { public int rank() { double eps = ulp(1.0); double tol = max(_m,_n)*_s[0]*eps; int r = 0; for (int i=0; i<_mn; ++i) { if (_s[i]>tol) ++r; } return r; } DMatrixSvd(DMatrix a); DMatrix getU(); DMatrix getS(); double[] getSingularValues(); DMatrix getV(); DMatrix getVTranspose(); double norm2(); double cond();... | @Test public void testRank() { DMatrix a = new DMatrix(new double[][]{ {1.0, 3.0}, {7.0, 9.0}, }); DMatrixSvd svda = new DMatrixSvd(a); assertEqualExact(svda.rank(),2); DMatrix b = new DMatrix(new double[][]{ {1.0, 3.0}, {7.0, 9.0}, {0.0, 0.0}, }); DMatrixSvd svdb = new DMatrixSvd(b); assertEqualExact(svdb.rank(),2); D... |
Geometry { public static double inCircle( double xa, double ya, double xb, double yb, double xc, double yc, double xd, double yd) { double adx = xa - xd; double bdx = xb - xd; double cdx = xc - xd; double ady = ya - yd; double bdy = yb - yd; double cdy = yc - yd; double bdxcdy = bdx * cdy; double cdxbdy = cdx * bdy; do... | @Test public void testInCircle() { float xxxx = 3.14159f; float yyyy = 1.00e15f; float pa[] = {xxxx,0.0f}; float pb[] = {0.0f,yyyy}; float pc[] = {0.0f,0.0f}; float pd[] = {xxxx,yyyy}; double ra,rf; trace(""); ra = Geometry.inCircle(pa,pb,pc,pd); rf = Geometry.inCircleFast(pa,pb,pc,pd); trace("0 inCircle: "+String.form... |
Geometry { public static double inSphere( double xa, double ya, double za, double xb, double yb, double zb, double xc, double yc, double zc, double xd, double yd, double zd, double xe, double ye, double ze) { double aex = xa - xe; double bex = xb - xe; double cex = xc - xe; double dex = xd - xe; double aey = ya - ye; d... | @Test public void testInSphere() { float xxxx = 1.0f; float yyyy = FLT_PI; float zzzz = 1.0e6f; float pa[] = {xxxx,0.0f,0.0f}; float pb[] = {0.0f,yyyy,0.0f}; float pc[] = {0.0f,0.0f,zzzz}; float pd[] = {0.0f,0.0f,0.0f}; float pe[] = {xxxx,yyyy,zzzz}; double ra,rf; trace(""); ra = Geometry.inSphere(pa,pb,pc,pd,pe); rf =... |
Geometry { public static double leftOfLine( double xa, double ya, double xb, double yb, double xc, double yc) { double detleft = (xa-xc)*(yb-yc); double detright = (ya-yc)*(xb-xc); double det = detleft-detright; double detsum; if (detleft>0.0) { if (detright<=0.0) { return det; } else { detsum = detleft+detright; } } e... | @Test public void testLeftOfLine() { float xxxx = 2.0f; float yyyy = 1.0f; float aaaa = 1.0e15f; float pa[] = {1.0f*xxxx,1.0f*yyyy}; float pb[] = {2.0f*xxxx,2.0f*yyyy}; float pc[] = {aaaa*xxxx,aaaa*yyyy}; double ra,rf; trace(""); ra = Geometry.leftOfLine(pa,pb,pc); rf = Geometry.leftOfLineFast(pa,pb,pc); trace("0 leftO... |
Geometry { public static double leftOfPlane( double xa, double ya, double za, double xb, double yb, double zb, double xc, double yc, double zc, double xd, double yd, double zd) { double adx = xa - xd; double bdx = xb - xd; double cdx = xc - xd; double ady = ya - yd; double bdy = yb - yd; double cdy = yc - yd; double ad... | @Test public void testLeftOfPlane() { float xxxx = 1.0f; float yyyy = 1.0f; float zzzz = 1.0e15f; float pa[] = {xxxx,0.0f,0.1f}; float pb[] = {0.0f,yyyy,3.3f}; float pc[] = {0.0f,yyyy,6.7f}; float pd[] = {xxxx,0.0f,zzzz}; double ra,rf; trace(""); ra = Geometry.leftOfPlane(pa,pb,pc,pd); rf = Geometry.leftOfPlaneFast(pa,... |
Geometry { public static void centerCircle3D( double xa, double ya, double za, double xb, double yb, double zb, double xc, double yc, double zc, double[] po) { double acx = xa - xc; double acy = ya - yc; double acz = za - zc; double bcx = xb - xc; double bcy = yb - yc; double bcz = zb - zc; double acs = acx*acx+acy*acy... | @Test public void testCenterCircle3D() { double[] po = {0.0,0.0,0.0}; Geometry.centerCircle3D(0,1,0, 0,1,1, 0,0,1, po); assertTrue(po[0]==0.0); assertTrue(po[1]==0.5); assertTrue(po[2]==0.5); Geometry.centerCircle3D(0,0,1, 1,0,1, 1,0,0, po); assertTrue(po[0]==0.5); assertTrue(po[1]==0.0); assertTrue(po[2]==0.5); Geomet... |
TridiagonalFMatrix { public void solve(float[] r, float[] u) { if (_w==null) _w = new float[_n]; float t = _b[0]; u[0] = r[0]/t; for (int j=1; j<_n; ++j) { _w[j] = _c[j-1]/t; t = _b[j]-_a[j]*_w[j]; u[j] = (r[j]-_a[j]*u[j-1])/t; } for (int j=_n-1; j>0; --j) u[j-1] -= _w[j]*u[j]; } TridiagonalFMatrix(int n); Tridiagonal... | @Test public void testSolve() { int n = 100; float[] a = randfloat(n); float[] b = randfloat(n); float[] c = randfloat(n); for (int i=0; i<n; ++i) b[i] += a[i]+c[i]; TridiagonalFMatrix t = new TridiagonalFMatrix(n,a,b,c); float[] r = randfloat(n); float[] u = zerofloat(n); t.solve(r,u); float[] s = t.times(u); assertEq... |
DMatrixQrd { public boolean isFullRank() { for (int j=0; j<_n; ++j) { if (_rdiag[j]==0.0) return false; } return true; } DMatrixQrd(DMatrix a); boolean isFullRank(); DMatrix getQ(); DMatrix getR(); DMatrix solve(DMatrix b); } | @Test public void testRankDeficient() { DMatrix a = new DMatrix(new double[][]{ {0.0, 0.0}, {3.0, 4.0}, }); DMatrixQrd qrd = new DMatrixQrd(a); assertFalse(qrd.isFullRank()); } |
ColorMap { public static float[] rgbToHsl(float r, float g, float b) { float h,s,l; float[] hsl = new float[3]; float min = min(min(r,g),b); float max = max(max(r,g),b); l = (max+min)/2f; if (max==min) h = s = 0.0f; else { float diff = max - min; s = (l>0.5f) ? diff / (2f - max - min) : diff / (max + min); if (max==r) ... | @Test public void testRgbToHsl() { float r,g,b; float h,s,l; for (int i=0; i<_rgbhsl.length; ++i) { r = _rgbhsl[i][0]; g = _rgbhsl[i][1]; b = _rgbhsl[i][2]; h = _rgbhsl[i][3]; s = _rgbhsl[i][4]; l = _rgbhsl[i][5]; float[] expected = { h, s, l }; float[] test = ColorMap.rgbToHsl(r,g,b); assertEquals(expected[0],test[0],... |
ColorMap { public static float[] hslToRgb(float h, float s, float l) { float r = 0, g = 0, b = 0; float c = (1 - Math.abs(2*l-1)) * s; float x = c * (1 - Math.abs((h/60.0f)%2-1)); float m = l - c/2.0f; if (h>= 0 && h< 60) { r = c; g = x; b = 0;} else if (h>= 60 && h<120) { r = x; g = c; b = 0;} else if (h>=120 && h<180... | @Test public void testHslToRgb() { float r,g,b; float h,s,l; for (int i=0; i<_rgbhsl.length; ++i) { r = _rgbhsl[i][0]; g = _rgbhsl[i][1]; b = _rgbhsl[i][2]; h = _rgbhsl[i][3]; s = _rgbhsl[i][4]; l = _rgbhsl[i][5]; float[] expected = { r, g, b }; float[] test = ColorMap.hslToRgb(h,s,l); assertEquals(expected[0],test[0],... |
Units implements Cloneable { public static synchronized boolean define(String name, boolean plural, String definition) throws UnitsFormatException { return addDefinition(name,plural,definition); } Units(); Units(String definition); Object clone(); boolean equals(Object object); boolean equals(Units units); float toSI(... | @Test public void testDefine() { boolean isValid, defined; try { isValid = Units.isValidDefinition("degrees F"); assertTrue(isValid); Units.define("degrees F",false,"degF"); defined = Units.isDefined("degrees F"); assertTrue(defined); isValid = Units.isValidDefinition("degrees C"); assertTrue(isValid); Units.define("de... |
ColorMap { public static float[] rgbToCieLab(float[] rgb) { float[] xyz = rgbToCieXyz(rgb); float Xn = 95.047f; float Yn = 100.000f; float Zn = 108.883f; xyz[0]/=Xn; xyz[1]/=Yn; xyz[2]/=Zn; return cieXyzToCieLab(xyz); } ColorMap(IndexColorModel colorModel); ColorMap(double vmin, double vmax, IndexColorModel colorModel... | @Test public void testRgbToCieLab() { float r,g,b; float Ls,as,bs; for (int i=0; i<_rgbcielab.length; ++i) { r = _rgbcielab[i][0]; g = _rgbcielab[i][1]; b = _rgbcielab[i][2]; Ls = _rgbcielab[i][3]; as = _rgbcielab[i][4]; bs = _rgbcielab[i][5]; float[] expected = { Ls, as, bs }; float[] test = ColorMap.rgbToCieLab(r,g,b... |
ColorMap { public static float[] cieLabToRgb(float[] lab) { float[] xyz = cieLabToCieXyz(lab); float Xn = 95.047f; float Yn = 100.000f; float Zn = 108.883f; xyz[0]*=Xn; xyz[1]*=Yn; xyz[2]*=Zn; float[] rgb = cieXyzToRgb(xyz); rgb[0] = min(1.0f,max(0.0f,rgb[0])); rgb[1] = min(1.0f,max(0.0f,rgb[1])); rgb[2] = min(1.0f,max... | @Test public void testCieLabToRgb() { float r,g,b; float Ls,as,bs; for (int i=0; i<_rgbcielab.length; ++i) { r = _rgbcielab[i][0]; g = _rgbcielab[i][1]; b = _rgbcielab[i][2]; Ls = _rgbcielab[i][3]; as = _rgbcielab[i][4]; bs = _rgbcielab[i][5]; float[] expected = { r, g, b }; float[] test = ColorMap.cieLabToRgb(Ls,as,bs... |
SincInterpolator { public static SincInterpolator fromErrorAndFrequency( double emax, double fmax) { return new SincInterpolator(emax,fmax,0); } SincInterpolator(); private SincInterpolator(double emax,double fmax,int lmax); static SincInterpolator fromErrorAndLength(
double emax, int lmax); static SincInterpolato... | @Test public void testErrorAndFrequency() { for (double emax:_emaxs) { for (double fmax:_fmaxs) { SincInterpolator si = SincInterpolator.fromErrorAndFrequency(emax,fmax); testInterpolator(si); } } } |
SincInterpolator { public static SincInterpolator fromErrorAndLength( double emax, int lmax) { return new SincInterpolator(emax,0.0,lmax); } SincInterpolator(); private SincInterpolator(double emax,double fmax,int lmax); static SincInterpolator fromErrorAndLength(
double emax, int lmax); static SincInterpolator fr... | @Test public void testErrorAndLength() { for (double emax:_emaxs) { for (int lmax:_lmaxs) { SincInterpolator si = SincInterpolator.fromErrorAndLength(emax,lmax); testInterpolator(si); } } } |
SincInterpolator { public static SincInterpolator fromFrequencyAndLength( double fmax, int lmax) { return new SincInterpolator(0.0,fmax,lmax); } SincInterpolator(); private SincInterpolator(double emax,double fmax,int lmax); static SincInterpolator fromErrorAndLength(
double emax, int lmax); static SincInterpolato... | @Test public void testFrequencyAndLength() { for (double fmax:_fmaxs) { for (int lmax:_lmaxs) { if ((1.0-2.0*fmax)*lmax>1.0) { SincInterpolator si = SincInterpolator.fromFrequencyAndLength(fmax,lmax); testInterpolator(si); } } } } |
SincInterpolator { public void accumulate( double xa, float ya, int nxu, double dxu, double fxu, float[] yu) { double xscale = 1.0/dxu; double xshift = _lsinc-fxu*xscale; int nxum = nxu-_lsinc; accumulate(xscale,xshift,nxum,xa,ya,nxu,yu); } SincInterpolator(); private SincInterpolator(double emax,double fmax,int lmax)... | @Test public void testAccumulate() { Random random = new Random(123456); for (int repeat=0; repeat<5; ++repeat) { for (SincInterpolator.Extrapolation extrapolation: SincInterpolator.Extrapolation.values()) { int nxu = 201; double fxu = Math.PI; double dxu = Math.E; double exu = fxu + dxu*(nxu-1); float[] yu = new float... |
RecursiveExponentialFilter { public void apply(float[] x, float[] y) { apply1(x,y); } RecursiveExponentialFilter(double sigma); RecursiveExponentialFilter(double sigma1, double sigma23); RecursiveExponentialFilter(
double sigma1, double sigma2, double sigma3); void setEdges(Edges edges); void apply(float[] x, flo... | @Test public void testFrequencyResponse() { int n = 501; double sigma = 4.0; float[] x = new float[n]; x[n/2] = 1.0f; float[] ye = new float[n]; float[] yg = new float[n]; RecursiveExponentialFilter ref = new RecursiveExponentialFilter(sigma); RecursiveGaussianFilter rgf = new RecursiveGaussianFilter(sigma); ref.apply(... |
HilbertTransformFilter { public void apply(int n, float[] x, float[] y) { Conv.conv(_filter.length,-(_filter.length-1)/2,_filter,n,0,x,n,0,y); } HilbertTransformFilter(); HilbertTransformFilter(int nmax, float emax,
float fmin, float fmax); void apply(int n, float[] x, float[] y); int ... | @Test public void testApply() { int[] nmax_test = {NMAX_DEFAULT,100000,100000,100000,100000}; float[] emax_test = {EMAX_DEFAULT,0.010f,0.010f,0.001f,0.001f}; float[] fmin_test = {FMIN_DEFAULT,0.050f,0.025f,0.100f,0.010f}; float[] fmax_test = {FMAX_DEFAULT,0.475f,0.450f,0.400f,0.490f}; int ntest = emax_test.length; for ... |
FftFilter { public float[] apply(float[] x) { float[] y = new float[x.length]; apply(x,y); return y; } FftFilter(float[] h); FftFilter(int kh, float[] h); FftFilter(float[][] h); FftFilter(int kh1, int kh2, float[][] h); FftFilter(float[][][] h); FftFilter(int kh1, int kh2, int kh3, float[][][] h); void setExtrapo... | @Test public void test1Random() { int ntest = 1000; int nmin = 1; int nmax = 8; for (int itest=0; itest<ntest; ++itest) { int nh = nmin+_random.nextInt(1+nmax-nmin); int nx = nmin+_random.nextInt(1+nmax-nmin); int ny = nx; int nz = nx; int kh = _random.nextInt(nh); float[] h = randfloat(nh); float[] x = randfloat(nx); ... |
Parallel { public static void loop(int end, LoopInt body) { loop(0,end,1,1,body); } static void loop(int end, LoopInt body); static void loop(int begin, int end, LoopInt body); static void loop(int begin, int end, int step, LoopInt body); static void loop(
int begin, int end, int step, int chunk, LoopInt body); st... | @Test public void testUnsafe() { final Unsafe<Worker> nts = new Unsafe<Worker>(); loop(20,new LoopInt() { public void compute(int i) { Worker w = nts.get(); if (w==null) nts.set(w=new Worker()); w.work(); } }); } |
Eigen { public static void solveSymmetric22(float[][] a, float[][] v, float[] d) { float a00 = a[0][0]; float a01 = a[0][1], a11 = a[1][1]; float v00 = 1.0f, v01 = 0.0f; float v10 = 0.0f, v11 = 1.0f; if (a01!=0.0f) { float tiny = 0.1f*sqrt(FLT_EPSILON); float c,r,s,t,u,vpr,vqr; u = a11-a00; if (abs(a01)<tiny*abs(u)) { ... | @Test public void testSymmetric22() { int nrand = 10000; double[][] v = new double[2][2]; double[] d = new double[2]; for (int irand=0; irand<nrand; ++irand) { double[][] a = randdouble(2,2); a = add(a, transpose(a)); Eigen.solveSymmetric22(a,v,d); check(a,v,d); } } |
Eigen { public static void solveSymmetric33(double[][] a, double[][] v, double[] d) { solveSymmetric33Jacobi(a,v,d); } static void solveSymmetric22(float[][] a, float[][] v, float[] d); static void solveSymmetric22(double[][] a, double[][] v, double[] d); static void solveSymmetric33(double[][] a, double[][] v, double... | @Test public void testSymmetric33() { double[][] v = new double[3][3]; double[] d = new double[3]; int nrand = 10000; for (int irand=0; irand<nrand; ++irand) { double[][] a = makeRandomSymmetric33(); Eigen.solveSymmetric33(a,v,d); check(a,v,d); } }
@Test public void testSymmetric33Special() { double[][] v = new double[... |
LocalOrientFilter { public void apply(float[][] x, float[][] theta, float[][] u1, float[][] u2, float[][] v1, float[][] v2, float[][] eu, float[][] ev, float[][] el) { float[][][] t = new float[8][][]; int nt = 0; if (theta!=null) t[nt++] = theta; if (u1!=null) t[nt++] = u1; if (u2!=null) t[nt++] = u2; if (v1!=null) t[... | @Test public void test2() { double sigma = 8.0; int n1 = 1+4*(int)(3*sigma); int n2 = n1+2; LocalOrientFilter lof = new LocalOrientFilter(sigma); float pi = FLT_PI; float[] dips = {-0.49f*pi,-0.20f*pi,-0.01f,0.01f,0.20f*pi,0.49f*pi}; for (float dip:dips) { float k = 0.3f; float c = k*cos(dip); float s = k*sin(dip); flo... |
Real1 { public Real1 plus(Real1 ra) { return add(this,ra); } Real1(Sampling s); Real1(float[] v); Real1(Sampling s, float[] v); Real1(int n, double d, double f); Real1(int n, double d, double f, float[] v); Real1(Real1 r); Sampling getSampling(); float[] getValues(); Real1 resample(Sampling s); Real1 plus(Real1 ra... | @Test public void testMath() { Real1 ra = RAMP1; Real1 rb = RAMP1; Real1 rc = ra.plus(rb); Real1 re = RAMP2; assertRealEquals(re,rc); } |
Real1 { public Real1 resample(Sampling s) { Sampling t = _s; int[] overlap = t.overlapWith(s); if (overlap!=null) { int ni = overlap[0]; int it = overlap[1]; int is = overlap[2]; Real1 rt = this; Real1 rs = new Real1(s); float[] xt = rt.getValues(); float[] xs = rs.getValues(); while (--ni>=0) xs[is++] = xt[it++]; retu... | @Test public void testResample() { Real1 ra = FILL1; Sampling sa = ra.getSampling(); int n1 = sa.getCount(); double d1 = sa.getDelta(); int m1 = n1/3; Sampling sb = sa.shift(-m1*d1); Real1 rb = ra.resample(sb); float[] vb = rb.getValues(); for (int i1=0; i1<m1; ++i1) assertEquals(0.0,vb[i1],0.0); for (int i1=m1; i1<n1;... |
RecursiveGaussianFilter { public void apply0(float[] x, float[] y) { _filter.applyN(0,x,y); } RecursiveGaussianFilter(double sigma, Method method); RecursiveGaussianFilter(double sigma); void apply0(float[] x, float[] y); void apply1(float[] x, float[] y); void apply2(float[] x, float[] y); void apply0X(float[][] x, f... | @Test public void test1() { float sigma = 10.0f; int n = 1+2*(int)(sigma*4.0f); int k = (n-1)/2; float[] x = zerofloat(n); float[] y = zerofloat(n); x[k] = 1.0f; float tolerance = 0.01f*gaussian(sigma,0.0f); RecursiveGaussianFilter rf = new RecursiveGaussianFilter(sigma); rf.apply0(x,y); for (int i=0; i<n; ++i) { float... |
MedianFinder { public float findMedian(float[] x) { Check.argument(_n==x.length,"length of x is valid"); copy(x,_x); int k = (_n-1)/2; quickPartialSort(k,_x); float xmed = _x[k]; if (_n%2==0) { float xmin = _x[_n-1]; for (int i=_n-2; i>k; --i) if (_x[i]<xmin) xmin = _x[i]; xmed = 0.5f*(xmed+xmin); } return xmed; } Medi... | @Test public void testUnweighted() { Random r = new Random(); int ntest = 100; for (int itest=0; itest<ntest; ++itest) { int n = 1+(r.nextBoolean()?r.nextInt(100):r.nextInt(10)); float[] f = randfloat(n); float[] w = fillfloat(1.0f,n); if (r.nextBoolean()) { for (int i=n/4; i<3*n/4; ++i) f[i] = f[0]; } MedianFinder mf ... |
RecursiveGaussianFilter { public void apply00(float[][] x, float[][] y) { _filter.applyXN(0,x,y); _filter.applyNX(0,y,y); } RecursiveGaussianFilter(double sigma, Method method); RecursiveGaussianFilter(double sigma); void apply0(float[] x, float[] y); void apply1(float[] x, float[] y); void apply2(float[] x, float[] y... | @Test public void test2() { float sigma = 10.0f; int n1 = 1+2*(int)(sigma*4.0f); int n2 = n1+2; int k1 = (n1-1)/2; int k2 = (n2-1)/2; float[][] x = zerofloat(n1,n2); float[][] y = zerofloat(n1,n2); x[k2][k1] = 1.0f; float tolerance = 0.01f*gaussian(sigma,0.0f,0.0f); RecursiveGaussianFilter rf = new RecursiveGaussianFil... |
RecursiveGaussianFilter { public void apply000(float[][][] x, float[][][] y) { _filter.applyXXN(0,x,y); _filter.applyXNX(0,y,y); _filter.applyNXX(0,y,y); } RecursiveGaussianFilter(double sigma, Method method); RecursiveGaussianFilter(double sigma); void apply0(float[] x, float[] y); void apply1(float[] x, float[] y); ... | @Test public void test3() { float sigma = 10.0f; int n1 = 1+2*(int)(sigma*4.0f); int n2 = n1+2; int n3 = n2+2; int k1 = (n1-1)/2; int k2 = (n2-1)/2; int k3 = (n3-1)/2; float[][][] x = zerofloat(n1,n2,n3); float[][][] y = zerofloat(n1,n2,n3); x[k3][k2][k1] = 1.0f; float tolerance = 0.01f*gaussian(sigma,0.0f,0.0f); Recur... |
SymmetricTridiagonalFilter { private static SymmetricTridiagonalFilter makeRandomFilter() { java.util.Random r = new java.util.Random(); float af,ai,al,b; boolean aeq2b = r.nextBoolean(); boolean abneg = r.nextBoolean(); boolean afzs = r.nextBoolean(); boolean alzs = r.nextBoolean(); if (aeq2b && afzs==true && alzs==tr... | @Test private static SymmetricTridiagonalFilter makeRandomFilter() { java.util.Random r = new java.util.Random(); float af,ai,al,b; boolean aeq2b = r.nextBoolean(); boolean abneg = r.nextBoolean(); boolean afzs = r.nextBoolean(); boolean alzs = r.nextBoolean(); if (aeq2b && afzs==true && alzs==true) { if (r.nextBoolean... |
LocalShiftFinder { public void find1( int min1, int max1, float[] f, float[] g, float[] u) { findShifts(min1,max1,f,g,u,null,null); } LocalShiftFinder(double sigma); LocalShiftFinder(double sigma1, double sigma2); LocalShiftFinder(double sigma1, double sigma2, double sigma3); void setInterpolateDisplacements(boolean ... | @Test public void testCosine() { float w = 0.02f*2.0f*FLT_PI; int n1 = 1001; float shift = 10.0f; float sigma = 8.0f*shift; float[] f = cos(rampfloat(w*shift,w,n1)); float[] g = cos(rampfloat(0.0f,w,n1)); float[] u = new float[n1]; float[] c = new float[n1]; float[] d = new float[n1]; int min1 = -2*(int)shift; int max1... |
BicubicInterpolator2 { public float interpolate(float x1, float x2) { return interpolate00(x1,x2); } BicubicInterpolator2(float[] x1, float[] x2, float[][] y); BicubicInterpolator2(
Method method1, Method method2,
float[] x1, float[] x2, float[][] y); BicubicInterpolator2(
Method method1, Method method2,... | @Test public void testArrayValues() { float[][][] xy = sampleTestFunction(11,13); float[] x1 = xy[0][0]; float[] x2 = xy[0][1]; float[][] y = xy[1]; float x1min = min(x1), x1max = max(x1); float x2min = min(x2), x2max = max(x2); BicubicInterpolator2 bi = makeInterpolator(x1,x2,y); int n1i = 101; int n2i = 102; float d1... |
TrilinearInterpolator3 { public float interpolate(float x1, float x2, float x3) { return interpolate000(x1,x2,x3); } TrilinearInterpolator3(
float[] x1, float[] x2, float[] x3, float[][][] y); TrilinearInterpolator3(
int n1, int n2, int n3,
float[] x1, float[] x2, float[] x3, float[][][] y); float interpo... | @Test public void testArrayValues() { float[][][][] xy = sampleTestFunction(11,12,13); float[] x1 = xy[0][0][0]; float[] x2 = xy[0][0][1]; float[] x3 = xy[0][0][2]; float[][][] y = xy[1]; float x1min = min(x1), x1max = max(x1); float x2min = min(x2), x2max = max(x2); float x3min = min(x3), x3max = max(x3); TrilinearInt... |
TricubicInterpolator3 { public float interpolate(float x1, float x2, float x3) { return interpolate000(x1,x2,x3); } TricubicInterpolator3(
float[] x1, float[] x2, float[] x3, float[][][] y); TricubicInterpolator3(
Method method1, Method method2, Method method3,
float[] x1, float[] x2, float[] x3, float[][]... | @Test public void testArrayValues() { float[][][][] xy = sampleTestFunction(11,12,13); float[] x1 = xy[0][0][0]; float[] x2 = xy[0][0][1]; float[] x3 = xy[0][0][2]; float[][][] y = xy[1]; float x1min = min(x1), x1max = max(x1); float x2min = min(x2), x2max = max(x2); float x3min = min(x3), x3max = max(x3); TricubicInte... |
BilinearInterpolator2 { public float interpolate(float x1, float x2) { return interpolate00(x1,x2); } BilinearInterpolator2(float[] x1, float[] x2, float[][] y); BilinearInterpolator2(
int n1, int n2, float[] x1, float[] x2, float[][] y); float interpolate(float x1, float x2); float interpolate00(float x1, float x... | @Test public void testArrayValues() { float[][][] xy = sampleTestFunction(11,13); float[] x1 = xy[0][0]; float[] x2 = xy[0][1]; float[][] y = xy[1]; float x1min = min(x1), x1max = max(x1); float x2min = min(x2), x2max = max(x2); BilinearInterpolator2 bi = makeInterpolator(x1,x2,y); int n1i = 101; int n2i = 102; float d... |
Projector { public void merge(Projector p) { if (p==null) return; double u0a = _u0; double u1a = _u1; double v0a = _v0; double v1a = _v1; double u0b = p._u0; double u1b = p._u1; double v0b = p._v0; double v1b = p._v1; if (signum(v1a-v0a)!=signum(v1b-v0b)) { u0b = 1.0-p._u1; u1b = 1.0-p._u0; v0b = p._v1; v1b = p._v0; } ... | @Test public void testMergeA () { Projector pa = new Projector(0, 1); Projector pb = new Projector(0, 1); pa.merge(pb); Projector expected = new Projector(0,1); assertVeryClose(expected,pa); }
@Test public void testMergeB () { Projector pa = new Projector(0, 1); Projector pb = new Projector(1, 0); pa.merge(pb); Project... |
ArrayQueue { public E first() { if (_size==0) throw new NoSuchElementException(); @SuppressWarnings("unchecked") E e = (E)_array[_first]; return e; } ArrayQueue(); ArrayQueue(int capacity); void add(E e); E first(); E remove(); boolean isEmpty(); void ensureCapacity(int capacity); int size(); void trimToSize(); } | @Test(expectedExceptions = NoSuchElementException.class) public void testEmptyQueueFirstElementThrowsException() { aq.first(); } |
Projector { public AxisScale getScale() { return _scaleType; } Projector(double v0, double v1); Projector(double v0, double v1, AxisScale scale); Projector(double v0, double v1, double u0, double u1); Projector(double v0, double v1, double u0, double u1, AxisScale s); Projector(Projector p); double u(double v); dou... | @Test public void testAutoLinear() { Projector p = new Projector(0.0, 100, 0.0, 1.0); assertTrue(p.getScale() == AxisScale.LINEAR); } |
ArrayQueue { public E remove() { if (_size==0) throw new NoSuchElementException(); @SuppressWarnings("unchecked") E e = (E)_array[_first]; ++_first; if (_first==_length) _first = 0; --_size; if (_size*3<_length) resize(_size*2); return e; } ArrayQueue(); ArrayQueue(int capacity); void add(E e); E first(); E remove(); ... | @Test(expectedExceptions = NoSuchElementException.class) public void testEmptyQueueRemoveElementThrowsException() { aq.remove(); } |
AtomicFloat extends Number implements java.io.Serializable { public final float get() { return f(_ai.get()); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float update); final boolean weakCompareA... | @Test public void testDefaultConstructor() { assertEquals(0.0,af.get(),epsilon); }
@Test public void testConstructorSingleParameter() { float expected = RANDOM.nextFloat(); AtomicFloat af = new AtomicFloat(expected); assertEquals(expected,af.get(),epsilon); } |
AtomicFloat extends Number implements java.io.Serializable { public final void set(float value) { _ai.set(i(value)); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float update); final boolean weak... | @Test public void testSet() { float expected = RANDOM.nextFloat(); af.set(expected); assertEquals(expected, af.get(),epsilon); } |
AtomicFloat extends Number implements java.io.Serializable { public final float addAndGet(float delta) { for (;;) { int iexpect = _ai.get(); float expect = f(iexpect); float update = expect+delta; int iupdate = i(update); if (_ai.compareAndSet(iexpect,iupdate)) return update; } } AtomicFloat(); AtomicFloat(float value... | @Test public void testAddAndGet() { float expected = 0.0f; float actual; for (int i=0; i<10; ++i) { float nf = RANDOM.nextFloat(); expected += nf; actual = af.addAndGet(nf); assertEquals(expected, actual,epsilon); } } |
CleanFormatter extends Formatter { @Override public synchronized String format(LogRecord record) { String message = formatMessage(record); if (message == null) return null; if (message.length() == 0) return message; message = Localize.filter(message, record.getResourceBundle()); if (message.endsWith("\\")) { message = ... | @Test public void testFormatter() { CleanHandler.setDefaultHandler(); Logger logger = Logger.getLogger("edu.mines.jtk.util.CleanFormatter"); CleanFormatter cf = new CleanFormatter(); String[] messages = new String[] {"one", "two", "three"}; Level[] levels = new Level[] {Level.INFO, Level.WARNING, Level.SEVERE}; String[... |
AtomicFloat extends Number implements java.io.Serializable { public final boolean compareAndSet(float expect, float update) { return _ai.compareAndSet(i(expect),i(update)); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compa... | @Test public void testCompareAndSet() { af.compareAndSet(1.0f,2.0f); assertEquals(0.0f,af.get()); af.compareAndSet(0.0f,1.0f); assertEquals(1.0f,af.get()); } |
AtomicFloat extends Number implements java.io.Serializable { public final boolean weakCompareAndSet(float expect, float update) { return _ai.weakCompareAndSet(i(expect),i(update)); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boole... | @Test public void testWeakCompareAndSet() { af.weakCompareAndSet(0.0f,1.0f); assertEquals(1.0f,af.get()); } |
AtomicFloat extends Number implements java.io.Serializable { public final float incrementAndGet() { return addAndGet(1.0f); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float update); final boole... | @Test public void testIncrementAndGet() { float val; for (int i=0; i<10; ++i) { val = af.get(); assertEquals((float)(i ),val,1.0E-8); val = af.incrementAndGet(); assertEquals((float)(i+1),val,1.0E-8); val = af.get(); assertEquals((float)(i+1),val,1.0E-8); } } |
AtomicFloat extends Number implements java.io.Serializable { public final float decrementAndGet() { return addAndGet(-1.0f); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float update); final bool... | @Test public void testDecrementAndGet() { float val = 10.0f; af.set(val); for (int i=10; i>0; --i) { val = af.get(); assertEquals((float)(i ),val,1.0E-8); val = af.decrementAndGet(); assertEquals((float)(i-1),val,1.0E-8); val = af.get(); assertEquals((float)(i-1),val,1.0E-8); } } |
AtomicFloat extends Number implements java.io.Serializable { public final float getAndIncrement() { return getAndAdd(1.0f); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float update); final boole... | @Test public void testGetAndIncrement() { float val; for (int i=0; i<10; ++i) { val = af.get(); assertEquals((float)(i ),val,1.0E-8); val = af.getAndIncrement(); assertEquals((float)(i ),val,1.0E-8); val = af.get(); assertEquals((float)(i+1),val,1.0E-8); } } |
AtomicFloat extends Number implements java.io.Serializable { public final float getAndDecrement() { return getAndAdd(-1.0f); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float update); final bool... | @Test public void testGetAndDecrement() { float val = 10.0f; af.set(val); for (int i=10; i>0; --i) { val = af.get(); assertEquals((float)(i ),val,1.0E-8); val = af.getAndDecrement(); assertEquals((float)(i ),val,1.0E-8); val = af.get(); assertEquals((float)(i-1),val,1.0E-8); } } |
AtomicFloat extends Number implements java.io.Serializable { public final float getAndSet(float value) { return f(_ai.getAndSet(i(value))); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float upda... | @Test public void testGetAndSet() { float expected0 = RANDOM.nextFloat(); float expected1 = RANDOM.nextFloat(); AtomicFloat af = new AtomicFloat(expected0); float actual0 = af.getAndSet(expected1); float actual1 = af.get(); assertEquals(expected0,actual0,epsilon); assertEquals(expected1,actual1,epsilon); } |
AtomicDouble extends Number implements java.io.Serializable { public final double get() { return d(_al.get()); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(double expect, double update); final boolean w... | @Test public void testDefaultConstructor() { assertEquals(0.0,ad.get(),epsilon); }
@Test public void testConstructorSingleParameter() { double expected = RANDOM.nextDouble(); AtomicDouble ad = new AtomicDouble(expected); assertEquals(expected,ad.get(),epsilon); } |
AtomicDouble extends Number implements java.io.Serializable { public final void set(double value) { _al.set(l(value)); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(double expect, double update); final b... | @Test public void testSet() { double expected = RANDOM.nextDouble(); ad.set(expected); assertEquals(expected, ad.get(),epsilon); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.