Update unit tests and add performance analyze
This commit is contained in:
30
src/test/java/com/cleverthis/interview/SolutionTestBase.java
Normal file
30
src/test/java/com/cleverthis/interview/SolutionTestBase.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.cleverthis.interview;
|
||||
|
||||
import com.cleverthis.interview.padlock.PadlockImpl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* This is a base class for verifying the correctness of the solution.
|
||||
*/
|
||||
public abstract class SolutionTestBase {
|
||||
|
||||
/**
|
||||
* Implement your solution in this function.
|
||||
* */
|
||||
protected abstract void solve(PadlockImpl padlock);
|
||||
|
||||
protected void verify(int numpadSize) {
|
||||
PadlockImpl padlock = new PadlockImpl(numpadSize);
|
||||
solve(padlock);
|
||||
assertTrue(padlock.isPasscodeCorrect());
|
||||
}
|
||||
|
||||
@Test
|
||||
void verify1to7() {
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
verify(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user