File tree Expand file tree Collapse file tree 2 files changed +4
-14
lines changed
extra/src/main/java/org/openscience/cdk/index Expand file tree Collapse file tree 2 files changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -73,14 +73,8 @@ public static boolean isValid(String casNumber) {
7373 String part1 = matcher .group (1 );
7474 String part2 = matcher .group (2 );
7575 String part3 = matcher .group (3 );
76- int part1value = Integer .parseInt (part1 );
77- if (part1value < 50 ) {
78- overall = false ;
79- // CAS numbers start at 50-00-0
80- } else {
81- int digit = CASNumber .calculateCheckDigit (part1 , part2 );
82- overall = overall && (digit == Integer .parseInt (part3 ));
83- }
76+ int digit = CASNumber .calculateCheckDigit (part1 , part2 );
77+ overall = overall && (digit == Integer .parseInt (part3 ));
8478 }
8579
8680 return overall ;
Original file line number Diff line number Diff line change 11/* Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project
2+ * 2020 Egon Willighagen <egon.willighagen@gmail.com>
23 *
34 * Contact: cdk-devel@lists.sourceforge.net
45 *
@@ -38,6 +39,7 @@ public class CASNumberTest extends CDKTestCase {
3839 @ Test
3940 public void testValidNumbers () {
4041 // valid cas numbers
42+ Assert .assertTrue (CASNumber .isValid ("36-88-4" ));
4143 Assert .assertTrue (CASNumber .isValid ("50-00-0" )); // formaldehyde
4244 Assert .assertTrue (CASNumber .isValid ("548-00-5" ));
4345 Assert .assertTrue (CASNumber .isValid ("2622-26-6" ));
@@ -59,12 +61,6 @@ public void testInvalidCheckDigits() {
5961 Assert .assertFalse (CASNumber .isValid ("50-00-9" ));
6062 }
6163
62- @ Test
63- public void testLargerThanFirst () {
64- // valid format, but wrong number, the first is 50-00-0
65- Assert .assertFalse (CASNumber .isValid ("3-21-4" ));
66- }
67-
6864 @ Test
6965 public void testWrongHyphenPositions () {
7066 // invalid format due to invalid hyphen positions
You can’t perform that action at this time.
0 commit comments