-
Notifications
You must be signed in to change notification settings - Fork 450
/
sort_helper_spec.rb
55 lines (51 loc) · 1.32 KB
/
sort_helper_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require File.expand_path('../../../../spec_helper', __FILE__)
module ProjectSpecs
describe Xcodeproj::XcodeSortString do
before do
@helper = XcodeSortString
end
#-------------------------------------------------------------------------#
describe 'In general' do
it 'sorts names like Xcode' do
unsorted_names = [
# spaces comparison
' a', ' a', 'a ',
# basic mix
'1a', '2 a', 'a1', 'a 2',
# pure integers
'1', '2', '10', '01',
# multi integers
'0.1.1', '0.1.2', '0.1.10', '0.1.01',
# multi equal integers
'A1B001', 'A01B1',
# case comparison
'A', 'a'
]
sorted = unsorted_names.sort_by { |s| @helper.new(s) }
# order given by Xcode 10.2 "Sort by Name" on macOS 10.14.4, English as primary language
sorted.should == [
' a',
' a',
'0.1.1',
'0.1.01',
'0.1.2',
'0.1.10',
'1',
'01',
'1a',
'2',
'2 a',
'10',
'a',
'A',
'a ',
'a 2',
'a1',
'A1B001',
'A01B1',
]
end
end
#-------------------------------------------------------------------------#
end
end