Skip to content

Commit

Permalink
fix: fix the code smell warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vvatanabe committed Aug 30, 2023
1 parent 41e29e1 commit c77f699
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/test/java/com/nulabinc/zxcvbn/EdgeCaseTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.nulabinc.zxcvbn;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;

public class EdgeCaseTest {
Expand All @@ -16,25 +18,25 @@ public void testWindowsNewlineInDate() {
buf.append((char) 10);
buf.append((char) 13);
buf.append("0101");
new Zxcvbn().measure(buf.toString());
assertNotNull(new Zxcvbn().measure(buf.toString()));
}

@Test
public void testUnixNewlineInDate() {
StringBuilder buf = new StringBuilder("PW2001");
buf.append((char) 13);
buf.append("0101");
new Zxcvbn().measure(buf.toString());
assertNotNull(new Zxcvbn().measure(buf.toString()));
}

@Test
public void testSpaceAfterDate() {
new Zxcvbn().measure("PW2009 ");
assertNotNull(new Zxcvbn().measure("PW2009 "));
}

/** Try to reproduce GitHub issue #34 */
@Test
public void testJustFourDigitNumber() {
new Zxcvbn().measure("8604 ");
assertNotNull(new Zxcvbn().measure("8604 "));
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/nulabinc/zxcvbn/MatchingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public SequenceMatchingSimpleTest(String password) {
public void testSequenceMatching() throws Exception {
Context context = StandardContext.build();
String msg = String.format("doesn't match length-%s sequences", password.length());
assertEquals(msg, new SequenceMatcher(context).execute(password).size(), 0);
assertEquals(msg, 0, new SequenceMatcher(context).execute(password).size());
}

@Parameterized.Parameters(name = "{0}")
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/nulabinc/zxcvbn/WipeableStringTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.nulabinc.zxcvbn;

import static junit.framework.TestCase.*;
import static org.junit.Assert.assertNotEquals;

import java.nio.CharBuffer;
import org.junit.Test;
Expand All @@ -14,8 +15,8 @@ public void testHashCode() {

@Test
public void testEquals() {
assertTrue(new WipeableString("hello").equals("hello"));
assertFalse(new WipeableString("goodbye").equals("hello"));
assertEquals("hello", new WipeableString("hello").toString());
assertNotEquals("hello", new WipeableString("goodbye").toString());
}

@Test
Expand Down

0 comments on commit c77f699

Please sign in to comment.