Skip to content

Commit

Permalink
Merge pull request #20 from pulibrary/issues-19-jrgriffiniii-lc-call-…
Browse files Browse the repository at this point in the history
…number-sort-test

Releases 0.9.1
  • Loading branch information
escowles authored Sep 14, 2018
2 parents 5a21fbd + ab3aad0 commit 85a5c76
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/lcsort/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Lcsort
VERSION = "0.9.0"
VERSION = "0.9.1"
end
40 changes: 25 additions & 15 deletions test/test_sort_orders.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'minitest_helper'

# Assorted tests of proper sort orders taken from various places.
# Assorted tests of proper sort orders taken from various places.
class TestSortOrders < Minitest::Test


Expand All @@ -25,14 +25,14 @@ def test_dueber_gem_examples
end

def test_stanford_examples
# some really terrible examples from
# some really terrible examples from
# https://github.com/sul-dlss/solrmarc-sw/blob/0e3c0e8cb3378b2992edc28b25c955943df67338/core/test/src/org/solrmarc/tools/CallNumberUnitTests.java#L1114

# We are taking from Stanford's "currentOrderList", which even in Stanford's
# code diverges from what they consider "properOrderList"

# We can't neccesarily sort all of Stanford's current order list the way
# Stanford does either -- we comment out elements that we can't handle below.
# Stanford does either -- we comment out elements that we can't handle below.

# Not sorting "35th" properly yet, at least according to stanford's librarians
list1 = [
Expand Down Expand Up @@ -85,13 +85,13 @@ def test_stanford_examples
"M5 .L3 2000 .K2 1880",

# first cutter L3 vol/part info: K.2,13 2001
# LCsort, nope, can't do this.
# LCsort, nope, can't do this.
#"M5 .L3 K.2,13 2001"
]
assert_sorted_order list3

# I think we're just lucky on MOST of these, we can't
# really do that volume information right. many commented out.
# really do that volume information right. many commented out.
list4 = [
# first cutter L3 second cutter K2
"M5.L3.K2",
Expand All @@ -107,7 +107,7 @@ def test_stanford_examples
"M5 .L3 K2 NO.1 1880", # vol info NO.1
"M5 .L3 K2 OP.7:NO.6 1880",
"M5 .L3 K2 OP.7:NO.6 1882",
"M5 .L3 K2 OP.7:NO.51 1880",
"M5 .L3 K2 OP.7:NO.51 1880",
"M5 .L3 K2 OP.8",
"M5 .L3 K2 OP.79",
"M5 .L3 K2 OP.789",
Expand All @@ -131,7 +131,7 @@ def test_stanford_examples
]
assert_sorted_order list5

list6 = [
list6 = [
# back to solid territory
"M5 L31",
"M5 L31902",
Expand All @@ -156,13 +156,13 @@ def test_with_large_decimals
end

# LC call numbers can have a 'date or other number', usually
# a year, in a cutter position, most commonly first.
# a year, in a cutter position, most commonly first.
#
# These currently sort correctly more or less accidentally --
# they are not parsed correctly, everything including and after
# the year ends up in 'extra', but they sort correctly ANYWAY.
# the year ends up in 'extra', but they sort correctly ANYWAY.
#
# We have a test to make sure it stays that way.
# We have a test to make sure it stays that way.
def test_year_cutter
list = [
"PX 101.1",
Expand All @@ -182,14 +182,14 @@ def test_year_cutter
end

# Make sure extra content sorts appropriately, BEFORE actual
# subsequent call number.
# subsequent call number.
def test_extras
assert_sorted_order([
"R 241",
"R 241 extra extra",
"R 241 .A2498",
"R 241 .A2498 extra extra",
"R 241 .G1",
"R 241 .G1",
"R 241 .G1 extra extra",
"R 241 .G1 .A1",
"R 241 .G1 .A1 extra extra",
Expand Down Expand Up @@ -257,6 +257,16 @@ def test_doon2
"JX 33 .A5 1968 .I4",
"JX 33 .A5 1969 .I31"
])

assert_sorted_order([
"M3 G32 1927q vol. 4",
"M3 G32 1934q vol. 7",
"M3 .G32 1951q vol. 3",
"M3 .G32 1966q vol. 2",
"M3 .G32 1972q",
"M3 G32 1984q vol. 6",
"M3 G32 2017q vol. 5"
])
end


Expand All @@ -276,8 +286,8 @@ def test_volume_extra

def assert_sorted_order(array)
# shuffle it up a bit deterministically, then sort it, and make sure
# it matches original, which was supposed to be in sorted order.
# it matches original, which was supposed to be in sorted order.
assert_equal array, array.reverse.rotate(array.length - 2).sort_by {|call_num| Lcsort.normalize(call_num)}
end

end
end

0 comments on commit 85a5c76

Please sign in to comment.