@@ -23,6 +23,19 @@ class StandardIdentifiersTest < ActiveSupport::TestCase
23
23
end
24
24
end
25
25
26
+ test 'ISBN-10 examples with incorrect check digits are not detected' do
27
+ # from wikipedia
28
+ samples = [ '99921-58-10-1' , '9971-5-0210-1' , '960-425-059-1' , '80-902734-1-1' , '85-359-0277-1' ,
29
+ '1-84356-028-1' , '0-684-84328-1' , '0-8044-2957-1' , '0-85131-041-1' , '93-86954-21-1' , '0-943396-04-1' ,
30
+ '0-9752298-0-1' ]
31
+
32
+ samples . each do |isbn |
33
+ actual = Detector ::StandardIdentifiers . new ( isbn ) . detections
34
+
35
+ assert_nil ( actual [ :isbn ] )
36
+ end
37
+ end
38
+
26
39
test 'ISBN-13 examples' do
27
40
samples = [ '978-99921-58-10-4' , '978-9971-5-0210-2' , '978-960-425-059-2' , '978-80-902734-1-2' ,
28
41
'978-85-359-0277-8' , '978-1-84356-028-9' , '978-0-684-84328-5' , '978-0-8044-2957-3' ,
@@ -36,6 +49,19 @@ class StandardIdentifiersTest < ActiveSupport::TestCase
36
49
end
37
50
end
38
51
52
+ test 'ISBN-13 examples with incorrect check digits are not detected' do
53
+ samples = [ '978-99921-58-10-1' , '978-9971-5-0210-1' , '978-960-425-059-1' , '978-80-902734-1-1' ,
54
+ '978-85-359-0277-1' , '978-1-84356-028-1' , '978-0-684-84328-1' , '978-0-8044-2957-1' ,
55
+ '978-0-85131-041-2' , '978-93-86954-21-1' , '978-0-943396-04-1' , '978-0-9752298-0-1' , '9798531132171' ,
56
+ '9798577456831' , '979-8-886-45174-1' , '9781319145441' ]
57
+
58
+ samples . each do |isbn |
59
+ actual = Detector ::StandardIdentifiers . new ( isbn ) . detections
60
+
61
+ assert_nil ( actual [ :isbn ] )
62
+ end
63
+ end
64
+
39
65
test 'not ISBNs' do
40
66
samples = [ 'orange cats like popcorn' , '1234-6798' , 'another ISBN not found here' , '99921-58-10-1' , '979-8-886-45174-1' ]
41
67
0 commit comments