Update unit tests and add performance analyze

This commit is contained in:
Rui Hu
2024-03-14 11:30:15 +08:00
parent 72ae4c0136
commit 6782050414
4 changed files with 88 additions and 20 deletions

View 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);
}
}
}