类org.junit.experimental.theories.suppliers.TestedOn源码实例Demo

下面列出了怎么用org.junit.experimental.theories.suppliers.TestedOn的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: gflogger   文件: BufferFormatterPropertyTest.java
@Theory( nullsAccepted = false )
public void appendedDoubleWithPrecisionParsesAsItselfWithTolerance( final Double value,
                                                                    @TestedOn( ints = { 0, 1, 2, 3, 10, 16, 19, 20 } )
                                                                    final int digits ) {
	final ByteBuffer buffer = ByteBuffer.allocate( 50 );
	BufferFormatter.append( buffer, value, digits );
	final String formatted = BufferFormatterTest.toString( buffer );

	final double parsedValue = Double.parseDouble( formatted );

	assertThat(
			".append(" + value + "," + digits + ") -> [" + formatted + "] -> [" + parsedValue + "]",
			parsedValue,
			closeTo( value, tolerance( digits ) )
	);
}
 
源代码2 项目: gflogger   文件: BufferFormatterPropertyTest.java
@Theory( nullsAccepted = false )
public void appendedDoubleWithPrecisionParsesAsItselfWithToleranceCB( final Double value,
                                                                      @TestedOn( ints = { 0, 1, 2, 3, 10, 16, 19, 20 } )
                                                                      final int digits ) {
	final CharBuffer buffer = CharBuffer.allocate( 50 );
	BufferFormatter.append( buffer, value, digits );
	final String formatted = BufferFormatterTest.toString( buffer );

	final double parsedValue = Double.parseDouble( formatted );

	assertThat(
			".append(" + value + "," + digits + ") -> [" + formatted + "] -> [" + parsedValue + "]",
			parsedValue,
			closeTo( value, tolerance( digits ) )
	);
}
 
源代码3 项目: helios   文件: DeploymentGroupTest.java
@Theory
public void testStopDeploymentGroup(
    @TestedOn(ints = { 0, 1 }) final int dgExistsInt,
    @TestedOn(ints = { 0, 1 }) final int tasksExistInt,
    @TestedOn(ints = { 0, 1 }) final int tasksExistWhenCommittingInt
) throws Exception {
  final boolean dgExists = dgExistsInt != 0;
  final boolean tasksExist = tasksExistInt != 0;
  final boolean tasksExistWhenCommitting = tasksExistWhenCommittingInt != 0;

  // To be able to simulate triggering the race condition in stopDeploymentGroup we need to do
  // some mocking, relying on that the implementation uses client.exists() to check for the
  // presence of tasks.
  final ZooKeeperClient client = spy(this.client);
  when(client.exists(Paths.statusDeploymentGroupTasks(GROUP_NAME)))
      .thenReturn(tasksExist ? mock(Stat.class) : null);

  final ZooKeeperMasterModel masterModel = newMasterModel(client);

  if (dgExists) {
    final DeploymentGroup dg = DeploymentGroup.newBuilder()
        .setName(GROUP_NAME)
        .build();
    masterModel.addDeploymentGroup(dg);
  }

  if (tasksExistWhenCommitting) {
    client.ensurePath(Paths.statusDeploymentGroupTasks());
    client.create(Paths.statusDeploymentGroupTasks(GROUP_NAME));
  }

  if (!dgExists) {
    exception.expect(DeploymentGroupDoesNotExistException.class);
  } else if (tasksExist != tasksExistWhenCommitting) {
    exception.expect(HeliosRuntimeException.class);
  }

  masterModel.stopDeploymentGroup(GROUP_NAME);

  // Verify that the state in ZK is correct:
  // * tasks are not present
  // * the status is set to FAILED
  //
  // When checking for the existence of the tasks make sure we use the client that doesn't have
  // the exists() method mocked out!
  assertNull(this.client.exists(Paths.statusDeploymentGroupTasks(GROUP_NAME)));
  final DeploymentGroupStatus status = masterModel.getDeploymentGroupStatus(GROUP_NAME);
  assertEquals(FAILED, status.getState());
}
 
源代码4 项目: latexdraw   文件: TestSetShapesBase.java
@Theory
public void testRemoveShapeIntKO(@SetShapeData final SetShapesProp shape, @TestedOn(ints = {-2, -1, 1, 2}) final int value) {
	shape.getShapes().add(sh1);
	shape.removeShape(value);
}
 
源代码5 项目: latexdraw   文件: TestRectangularShapeBase.java
@Theory
public void testGetPtAt(@RectangularData final RectangularShape shape, @TestedOn(ints = {-1, 0, 1, 2, 3}) final int i) {
	assertNotNull(shape.getPtAt(i));
}
 
源代码6 项目: latexdraw   文件: TestRectangularShapeBase.java
@Theory
public void testGetPtAtKO(@RectangularData final RectangularShape shape, @TestedOn(ints = {-2, 4}) final int i) {
	assertNull(shape.getPtAt(i));
}
 
源代码7 项目: latexdraw   文件: TestFreehand.java
@Theory
public void testGetSetInterval(@TestedOn(ints = {1, 10}) final int value) {
	shape.setInterval(value);
	assertEquals(value, shape.getInterval());
}
 
源代码8 项目: latexdraw   文件: TestControlPointShapeBase.java
@Theory
public void testGetFirstCtrlPtAt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int value) {
	assertNotNull(sh.getFirstCtrlPtAt(value));
}
 
源代码9 项目: latexdraw   文件: TestControlPointShapeBase.java
@Theory
public void testGetFirstCtrlPtAtKO(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {-2, 2}) final int value) {
	assertNull(sh.getFirstCtrlPtAt(value));
}
 
源代码10 项目: latexdraw   文件: TestControlPointShapeBase.java
@Theory
public void testGetSecondCtrlPtAt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int value) {
	assertNotNull(sh.getSecondCtrlPtAt(value));
}
 
源代码11 项目: latexdraw   文件: TestControlPointShapeBase.java
@Theory
public void testUpdateSecondControlPoints(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {-2, 2}) final int value) {
	assertNull(sh.getSecondCtrlPtAt(value));
}
 
源代码12 项目: latexdraw   文件: TestControlPointShapeBase.java
@Theory
public void testSetXFirstCtrlPt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int index) {
	sh.setXFirstCtrlPt(33d, index);
	assertEqualsDouble(33d, sh.getFirstCtrlPtAt(index).getX());
}
 
源代码13 项目: latexdraw   文件: TestControlPointShapeBase.java
@Theory
public void testSetYFirstCtrlPt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int index) {
	sh.setYFirstCtrlPt(33d, index);
	assertEqualsDouble(33d, sh.getFirstCtrlPtAt(index).getY());
}
 
源代码14 项目: latexdraw   文件: TestControlPointShapeBase.java
@Theory
public void testSetXSecondCtrlPt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int index) {
	sh.setXSecondCtrlPt(33d, index);
	assertEqualsDouble(33d, sh.getSecondCtrlPtAt(index).getX());
}
 
源代码15 项目: latexdraw   文件: TestControlPointShapeBase.java
@Theory
public void testSetYSecondCtrlPt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int index) {
	sh.setYSecondCtrlPt(33d, index);
	assertEqualsDouble(33d, sh.getSecondCtrlPtAt(index).getY());
}
 
源代码16 项目: latexdraw   文件: TestPlot.java
@Theory
public void testValidGetSetNbPlottedPoints(@TestedOn(ints = {2, 10, 200}) final int value) {
	shape.setNbPlottedPoints(value);
	assertEquals(value, shape.getNbPlottedPoints());
}
 
源代码17 项目: latexdraw   文件: TestPlot.java
@Theory
public void testValidGetSetNbPlottedPointsKO(@TestedOn(ints = {1, 0, -1}) final int value) {
	shape.setNbPlottedPoints(10);
	shape.setNbPlottedPoints(value);
	assertEquals(10, shape.getNbPlottedPoints());
}
 
源代码18 项目: latexdraw   文件: TestModifiablePointsShapeBase.java
@Theory
public void testSetPoint2KO2(@ModifPtShapeData final ModifiablePointsShape shape,
							@TestedOn(ints = {-2, 10}) final int value) {
	assertFalse(shape.setPoint(0, 0, value));
}
 
源代码19 项目: latexdraw   文件: TestStandardGridBase.java
@Theory
public void testGetSetLabelsSize(@StdGridData final StandardGrid shape, @TestedOn(ints = {0, 1, 10}) final int value) {
	shape.setLabelsSize(value);
	assertEquals(value, shape.getLabelsSize());
}
 
源代码20 项目: latexdraw   文件: TestGrid.java
@Theory
public void testGetSetGridDots(@TestedOn(ints = {0, 1, 10}) final int value) {
	shape.setGridDots(value);
	assertEquals(value, shape.getGridDots());
}
 
源代码21 项目: latexdraw   文件: TestGrid.java
@Theory
public void testGetSetSubGridDiv(@TestedOn(ints = {0, 1, 10}) final int value) {
	shape.setSubGridDiv(value);
	assertEquals(value, shape.getSubGridDiv());
}
 
源代码22 项目: latexdraw   文件: TestGrid.java
@Theory
public void testGetSetSubGridDots(@TestedOn(ints = {0, 1, 10}) final int value) {
	shape.setSubGridDots(value);
	assertEquals(value, shape.getSubGridDots());
}
 
 类所在包
 类方法
 同包方法