org.assertj.core.api.AbstractByteArrayAssert.containsOnly()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(27)

本文整理了Java中org.assertj.core.api.AbstractByteArrayAssert.containsOnly()方法的一些代码示例,展示了AbstractByteArrayAssert.containsOnly()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractByteArrayAssert.containsOnly()方法的具体详情如下:
包路径:org.assertj.core.api.AbstractByteArrayAssert
类名称:AbstractByteArrayAssert
方法名:containsOnly

AbstractByteArrayAssert.containsOnly介绍

[英]Verifies that the actual array contains only the given values and nothing else, in any order.

Example:

// assertions will pass 
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 1, (byte) 2, (byte) 3); 
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 2, (byte) 3, (byte) 1); 
assertThat(new byte[] { 1, 1, 2 }).containsOnly((byte) 1, (byte) 2); 
// assertions will fail 
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 1, (byte) 2, (byte) 3, (byte) 4); 
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 4, (byte) 7);

[中]验证实际数组是否仅包含给定值,而不包含其他任何顺序的值。
例子:

// assertions will pass 
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 1, (byte) 2, (byte) 3); 
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 2, (byte) 3, (byte) 1); 
assertThat(new byte[] { 1, 1, 2 }).containsOnly((byte) 1, (byte) 2); 
// assertions will fail 
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 1, (byte) 2, (byte) 3, (byte) 4); 
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 4, (byte) 7);

代码示例

代码示例来源:origin: zeebe-io/zeebe

/**
 * Verifies that the actual DeploymentResource's resource contains <b>only</b> the given byte elements and nothing else in whatever order.
 *
 * @param resource the given elements that should be contained in actual DeploymentResource's resource.
 * @return this assertion object.
 * @throws AssertionError if the actual DeploymentResource's resource does not contain all given byte elements and nothing else.
 */
public S hasOnlyResource(byte... resource) {
 // check that actual DeploymentResource we want to make assertions on is not null.
 isNotNull();
 // check that given byte varargs is not null.
 if (resource == null) failWithMessage("Expecting resource parameter not to be null.");
 // check with standard error message (use overridingErrorMessage before contains to set your own message).
 Assertions.assertThat(actual.getResource()).containsOnly(resource);
 // return the current assertion for method chaining
 return myself;
}

代码示例来源:origin: net.stickycode/sticky-coercion

@Test
public void bytes() {
 ArrayCoercion coercion = coercion();
 CoercionTarget coercionTarget = coercionTarget(byte[].class);
 assertThat(coercion.isApplicableTo(coercionTarget)).isTrue();
 assertThat((byte[]) coercion.coerce(coercionTarget, "45")).containsOnly((byte)45);
 assertThat((byte[]) coercion.coerce(coercionTarget, "45,127,-127")).containsOnly((byte)45, (byte)127, (byte)-127);
}

代码示例来源:origin: bonitasoft/bonita-engine

/**
 * Verifies that the actual BonitaConfiguration's resourceContent contains <b>only<b> the given byte elements and nothing else in whatever order.
 * 
 * @param resourceContent the given elements that should be contained in actual BonitaConfiguration's resourceContent.
 * @return this assertion object.
 * @throws AssertionError if the actual BonitaConfiguration's resourceContent does not contain all given byte elements and nothing else.
 */
public BonitaConfigurationAssert hasOnlyResourceContent(byte... resourceContent) {
 // check that actual BonitaConfiguration we want to make assertions on is not null.
 isNotNull();
 // check that given byte varargs is not null.
 if (resourceContent == null) failWithMessage("Expecting resourceContent parameter not to be null.");
 
 // check with standard error message (use overridingErrorMessage before contains to set your own message).
 Assertions.assertThat(actual.getResourceContent()).containsOnly(resourceContent);
 // return the current assertion for method chaining
 return this;
}

代码示例来源:origin: segmentio/analytics-android

queue.raf.seek(HEADER_LENGTH);
queue.raf.readFully(data, 0, firstElementPadding);
assertThat(data).containsOnly((byte) 0x00);
queue.raf.seek(endOfLastElement);
queue.raf.readFully(data, 0, readLength);
assertThat(data).containsOnly((byte) 0x00);

相关文章