本文整理匯總了Java中org.junit.jupiter.api.Assertions.assertTrue方法的典型用法代碼示例。如果您正苦於以下問題:Java Assertions.assertTrue方法的具體用法?Java Assertions.assertTrue怎麽用?Java Assertions.assertTrue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.jupiter.api.Assertions
的用法示例。
在下文中一共展示了Assertions.assertTrue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testClassPrimitiveArrayFieldWriting
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public <C> void testClassPrimitiveArrayFieldWriting() throws Exception {
ClassWrapper<TestClassFour> cw = wrapClass(TestClassFour.class);
Class<C> type = (Class<C>)double[].class;
Optional<FieldWrapper<C>> fieldOptinal = cw.getField("a", type);
Assertions.assertTrue(fieldOptinal.isPresent());
FieldWrapper<C> field = fieldOptinal.get();
double[] expected = new double[]{-2, -2, -2};
field.write((C)expected);
double[] actual = (double[]) field.read();
Assertions.assertEquals(-2D, actual[0]);
Assertions.assertEquals(-2D, actual[1]);
Assertions.assertEquals(-2D, actual[2]);
}
示例2: testCopyBasicFileAttributesFromNioToFuse
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testCopyBasicFileAttributesFromNioToFuse() {
Instant instant = Instant.ofEpochSecond(424242l, 42);
FileTime ftime = FileTime.from(instant);
BasicFileAttributes attr = Mockito.mock(BasicFileAttributes.class);
Mockito.when(attr.isDirectory()).thenReturn(true);
Mockito.when(attr.lastModifiedTime()).thenReturn(ftime);
Mockito.when(attr.creationTime()).thenReturn(ftime);
Mockito.when(attr.lastAccessTime()).thenReturn(ftime);
Mockito.when(attr.size()).thenReturn(42l);
FileAttributesUtil util = new FileAttributesUtil();
FileStat stat = new FileStat(jnr.ffi.Runtime.getSystemRuntime());
util.copyBasicFileAttributesFromNioToFuse(attr, stat);
Assertions.assertTrue((FileStat.S_IFDIR & stat.st_mode.intValue()) == FileStat.S_IFDIR);
Assertions.assertEquals(424242l, stat.st_mtim.tv_sec.get());
Assertions.assertEquals(42, stat.st_mtim.tv_nsec.intValue());
Assertions.assertEquals(424242l, stat.st_ctim.tv_sec.get());
Assertions.assertEquals(42, stat.st_ctim.tv_nsec.intValue());
Assumptions.assumingThat(Platform.IS_MAC || Platform.IS_WINDOWS, () -> {
Assertions.assertEquals(424242l, stat.st_birthtime.tv_sec.get());
Assertions.assertEquals(42, stat.st_birthtime.tv_nsec.intValue());
});
Assertions.assertEquals(424242l, stat.st_atim.tv_sec.get());
Assertions.assertEquals(42, stat.st_atim.tv_nsec.intValue());
Assertions.assertEquals(42l, stat.st_size.longValue());
}
示例3: getExistingDriverTest
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
/**
* Tries to get the mock plc driver which is part of this testsuite.
*/
@Test
@Tag("fast")
void getExistingDriverTest() throws PlcException {
MockConnection mockConnection = (MockConnection) new PlcDriverManager().getConnection("mock://some-cool-url");
Assertions.assertNull(mockConnection.getAuthentication());
Assertions.assertTrue(mockConnection.isConnected());
Assertions.assertTrue(!mockConnection.isClosed());
}
示例4: checkRead
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
private <T> void checkRead(MockConnection connection, PlcReadRequest request, T value) throws InterruptedException, ExecutionException {
// this is really a tests of our mock tooling but knowing it's behaving as expected
// will help identify problems in the adapter/supplier/consumer
connection.setDataValue(request.getReadRequestItems().get(0).getAddress(), value);
CompletableFuture<PlcReadResponse> cf = connection.read(request);
Assertions.assertTrue(cf.isDone());
PlcReadResponse response = cf.get();
Assertions.assertEquals(value, response.getResponseItems().get(0).getValues().get(0));
}
示例5: assertHasFunction
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
private static Function assertHasFunction(Context context) {
return args -> {
Validator.with(args).check(1);
val name = args[0].asString();
Assertions.assertTrue(context.functions().containsKey(name));
return NumberValue.ZERO;
};
}
示例6: assertTrue
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
private static Function assertTrue(Context context) {
return args -> {
Validator.with(args).check(1);
Assertions.assertTrue(args[0].asBoolean());
return NumberValue.ZERO;
};
}
示例7: testClassLoading
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testClassLoading() throws Exception {
SimpleClassLoader simpleClassLoader = new SimpleClassLoader(ClassLoader.getSystemClassLoader());
String className = getClass().getPackage().getName()+".GeneratedTestClass";
String classNameInternal = className.replaceAll("\\.", "/");
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, classNameInternal, null, Type.getInternalName(Object.class), null);
{
FieldVisitor fv = cw.visitField(ACC_PRIVATE + ACC_STATIC, "test", Type.getDescriptor(String.class), null, "hey");
fv.visitEnd();
}
{
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
cw.visitEnd();
}
cw.visitEnd();
/* Test class loading */
Class<?> generated = ClassLoaderTools.defineClass(simpleClassLoader, className, cw.toByteArray());
Assertions.assertNotNull(generated, "Class didn't load!");
Assertions.assertTrue(Reflect.getClass(className, simpleClassLoader).isPresent(),
"Class isn't present in classloader!");
Assertions.assertFalse(Reflect.getClass(className).isPresent()
, "Class is present in system class loader!");
/* Test field */
ClassWrapper<?> c = Reflect.construct(Reflect.wrapClass(generated));
Optional<FieldWrapper<String>> testFieldOptional = c.getField("test", String.class);
Assertions.assertTrue(testFieldOptional.isPresent(), "Test field is not present!");
Assertions.assertEquals("hey", testFieldOptional.get().read(), "Test field content didn't match!");
}
示例8: ignoredKeysHasSpecificDefaultValues
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void ignoredKeysHasSpecificDefaultValues() {
Assertions.assertTrue(FilteringJooq.DEFAULT_IGNORED_KEY_FOR_FILTERING.contains("sort"));
Assertions.assertTrue(FilteringJooq.DEFAULT_IGNORED_KEY_FOR_FILTERING.contains("page"));
Assertions.assertTrue(FilteringJooq.DEFAULT_IGNORED_KEY_FOR_FILTERING.contains("size"));
Assertions.assertEquals(3, FilteringJooq.DEFAULT_IGNORED_KEY_FOR_FILTERING.size());
}
示例9: testGTCompiler
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void testGTCompiler() {
// String result = compiler(" \"lfkdsk\" > \"lfk\" ", null);
// Assertions.assertTrue(Boolean.valueOf(result));
String result = compiler("123.111111d > 111.111111d", null);
Assertions.assertTrue(Boolean.valueOf(result));
result = compiler("123 > 123 ", null);
Assertions.assertFalse(Boolean.valueOf(result));
}
示例10: getValueWorksBasicOfMap
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void getValueWorksBasicOfMap() {
Assertions.assertFalse(filteringJooqImpl1.getValue(emptyMap, "myKey").isPresent());
Assertions.assertFalse(filteringJooqImpl1.getValue(notEmptyMap, "myKey").isPresent());
Assertions.assertFalse(filteringJooqImpl1.getValue(notEmptyMap, "myKey").isPresent());
Assertions.assertTrue(filteringJooqImpl1.getValue(notEmptyMap, "key1").isPresent());
}
示例11: testFieldListing
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testFieldListing() throws Exception {
ClassWrapper<TestClassFive> cw = wrapClass(TestClassFive.class);
List<FieldWrapper<?>> fields = cw.getFields();
Assertions.assertTrue(fields.size() == 2);
Assertions.assertTrue(fields.get(0).getType() == String.class);
Assertions.assertTrue(fields.get(1).getType() == String.class);
}
示例12: testClassPrimitiveFieldReading
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testClassPrimitiveFieldReading() throws Exception {
Class<?> testClass = TestClassOne.class;
ClassWrapper<?> cw = wrapClass(testClass);
Reflect.construct(cw);
Optional<FieldWrapper<Character>> fieldOptinal = cw.getField("a", char.class);
Assertions.assertTrue(fieldOptinal.isPresent());
FieldWrapper<Character> field = fieldOptinal.get();
char expected = 'a';
char actual = field.read();
Assertions.assertEquals(expected, actual);
}
示例13: testClassPrimitiveFieldWriting
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testClassPrimitiveFieldWriting() throws Exception {
Class<?> testClass = TestClassThree.class;
ClassWrapper<?> cw = wrapClass(testClass);
Reflect.construct(cw);
Optional<FieldWrapper<Character>> fieldOptinal = cw.getField("b", char.class);
Assertions.assertTrue(fieldOptinal.isPresent());
FieldWrapper<Character> field = fieldOptinal.get();
char expected = 'f';
field.write(expected);
char actual = field.read();
Assertions.assertEquals(expected, actual);
}
示例14: testIsFieldStatic
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testIsFieldStatic() throws Exception {
ClassWrapper<TestClassFour> cw = wrapClass(TestClassFour.class);
boolean isStatic = cw.getField("a", double[].class).get().isStatic();
Assertions.assertTrue(isStatic);
}
示例15: description
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void description() {
Assertions.assertNotNull(command.description());
Assertions.assertTrue(command.description().length() == 0);
}