Skip to content

Commit 00b4bb6

Browse files
committed
Fix coverage of MastCard account ranges
1 parent 7f28e86 commit 00b4bb6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/main/java/us/fatehi/creditcardnumber/CardBrand.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package us.fatehi.creditcardnumber;
99

1010
import static org.apache.commons.lang3.StringUtils.isBlank;
11-
1211
import java.util.regex.Pattern;
1312

1413
/**
@@ -43,7 +42,7 @@ public boolean test(final Integer length) {
4342
// MasterCard numbers start with the numbers 51 through 55, and 2221
4443
// through 2720
4544
MasterCard(
46-
"^(?:5[1-5][0-9]{2}|222[1-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]*$", new LengthCheck(16)),
45+
"^(?:5[1-5][0-9]{2}|222[1-9]|2[2-6][0-9]{2}|27[01][0-9]|2720)[0-9]*$", new LengthCheck(16)),
4746

4847
// American Express numbers start with 35 or 37
4948
AmericanExpress("^3[47][0-9]{2,}$", new LengthCheck(15)),
@@ -142,7 +141,7 @@ public static CardBrand from(final String accountNumber) {
142141
private final Predicate<Integer> lengthCheck;
143142

144143
CardBrand(final String patternRegEx, final Predicate<Integer> lengthCheck) {
145-
this.pattern = Pattern.compile(patternRegEx);
144+
pattern = Pattern.compile(patternRegEx);
146145
this.lengthCheck = lengthCheck;
147146
}
148147

src/test/java/us/fatehi/test/creditcardnumber/CardBrandTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ public void masterCard() {
132132

133133
@Test
134134
public void masterCard2Series() {
135-
final long[] longCardNumbers = {2221000000000009L, 2223000048400011L, 2223016768739313L};
135+
final long[] longCardNumbers = {
136+
2221000000000009L, 2223000048400011L, 2223016768739313L, 2235579080595222L
137+
};
136138
for (final long longCardNumber : longCardNumbers) {
137139
test(longCardNumber, CardBrand.MasterCard);
138140
}

0 commit comments

Comments
 (0)