Skip to content

Commit

Permalink
improve errno unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Aug 23, 2023
1 parent 30045e2 commit aa7c036
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package org.cryptomator.jfuse.linux.aarch64;

import org.cryptomator.jfuse.api.Errno;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.stream.Stream;

public class LinuxErrnoTest {

@DisplayName("make sure method is not a stub")
@DisplayName("make sure no errno method is not a stub")
@ParameterizedTest(name = "{0}()")
@ValueSource(strings = {"enoent", "enosys", "enomem", "eacces", "eio", "erofs", "ebadf", "eexist", "enotdir", "eisdir", "enotempty", "einval"})
public void testErrnoIsNotZero(String methodName) throws ReflectiveOperationException {
@MethodSource("errnoNameProvider")
public void testErrnoIsImplemented(String methodName) throws ReflectiveOperationException {
var errno = new LinuxErrno();
var method = LinuxErrno.class.getMethod(methodName);

Expand All @@ -19,4 +25,8 @@ public void testErrnoIsNotZero(String methodName) throws ReflectiveOperationExce
Assertions.assertNotEquals(0, result);
}

static Stream<String> errnoNameProvider() {
return Arrays.stream(Errno.class.getDeclaredMethods()).map(Method::getName);
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package org.cryptomator.jfuse.linux.amd64;

import org.cryptomator.jfuse.api.Errno;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.stream.Stream;

public class LinuxErrnoTest {

@DisplayName("make sure method is not a stub")
@DisplayName("make sure no errno method is not a stub")
@ParameterizedTest(name = "{0}()")
@ValueSource(strings = {"enoent", "enosys", "enomem", "eacces", "eio", "erofs", "ebadf", "eexist", "enotdir", "eisdir", "enotempty", "einval"})
public void testErrnoIsNotZero(String methodName) throws ReflectiveOperationException {
@MethodSource("errnoNameProvider")
public void testErrnoIsImplemented(String methodName) throws ReflectiveOperationException {
var errno = new LinuxErrno();
var method = LinuxErrno.class.getMethod(methodName);

Expand All @@ -19,4 +25,8 @@ public void testErrnoIsNotZero(String methodName) throws ReflectiveOperationExce
Assertions.assertNotEquals(0, result);
}

static Stream<String> errnoNameProvider() {
return Arrays.stream(Errno.class.getDeclaredMethods()).map(Method::getName);
}

}

0 comments on commit aa7c036

Please sign in to comment.