Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 Red Hat, Inc. and others.
* Copyright (c) 2000, 2025 Red Hat, Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -15,7 +15,7 @@
package org.eclipse.swt.tests.junit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertThrows;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Spinner;
Expand All @@ -37,23 +37,13 @@ public void setUp() {
@Override
@Test
public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() {
try {
spinner = new Spinner(null, 0);
fail("No exception thrown for parent == null");
}
catch (IllegalArgumentException e) {
}
int[] cases = {0, SWT.READ_ONLY, SWT.WRAP};
assertThrows("No exception thrown for parent == null", IllegalArgumentException.class,
() -> new Spinner(null, 0));
int[] cases = { 0, SWT.READ_ONLY, SWT.WRAP };
for (int style : cases)
spinner = new Spinner(shell, style);
}

@Override
@Test
public void test_computeSizeIIZ() {
// super class test is sufficient
}

@Test
public void test_getIncrement() {
int [] cases = {5,100,1000,1};
Expand All @@ -72,13 +62,9 @@ public void test_getDigits() {
spinner.setDigits(digits);
assertEquals(digits, spinner.getDigits());
}
try{
spinner.setDigits(-1);
fail("setDigits should have failed with illegal Argument");
}
catch(IllegalArgumentException e){
assertEquals(cases[cases.length-1], spinner.getDigits());
}
assertThrows("setDigits should have failed with illegal Argument", IllegalArgumentException.class,
() -> spinner.setDigits(-1));
assertEquals(cases[cases.length-1], spinner.getDigits());
}

@Test
Expand Down Expand Up @@ -132,11 +118,8 @@ public void test_getTextLimit() {
spinner.setTextLimit(value);
assertEquals(value, spinner.getTextLimit());
}
try {
spinner.setTextLimit(0);
fail("setTextLimit should have caused an expection with value 0");
} catch (Exception e) {
}
assertThrows("setTextLimit should have caused an expection with value 0", IllegalArgumentException.class,
() -> spinner.setTextLimit(0));
}

@Test
Expand Down
Loading