dcm_dict 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +156 -0
  3. data/COPYING +674 -0
  4. data/LICENSE +22 -0
  5. data/README.md +327 -0
  6. data/Rakefile +36 -0
  7. data/bin/dcm_dict_converter.rb +194 -0
  8. data/lib/dcm_dict.rb +46 -0
  9. data/lib/dcm_dict/dictionary/base_dictionary.rb +47 -0
  10. data/lib/dcm_dict/dictionary/base_record.rb +62 -0
  11. data/lib/dcm_dict/dictionary/data_element_dictionary.rb +117 -0
  12. data/lib/dcm_dict/dictionary/data_element_record.rb +93 -0
  13. data/lib/dcm_dict/dictionary/uid_dictionary.rb +82 -0
  14. data/lib/dcm_dict/dictionary/uid_record.rb +48 -0
  15. data/lib/dcm_dict/encoder/data_to_code.rb +79 -0
  16. data/lib/dcm_dict/error/dictionary_error.rb +30 -0
  17. data/lib/dcm_dict/ext/object_extension.rb +38 -0
  18. data/lib/dcm_dict/refine/array_refine.rb +34 -0
  19. data/lib/dcm_dict/refine/data_element_refine.rb +37 -0
  20. data/lib/dcm_dict/refine/internal/array_refine_internal.rb +97 -0
  21. data/lib/dcm_dict/refine/internal/hash_refine_internal.rb +71 -0
  22. data/lib/dcm_dict/refine/internal/string_refine_internal.rb +135 -0
  23. data/lib/dcm_dict/refine/string_refine.rb +35 -0
  24. data/lib/dcm_dict/refine/symbol_refine.rb +34 -0
  25. data/lib/dcm_dict/refine/uid_refine.rb +36 -0
  26. data/lib/dcm_dict/rubies/rb_ext.rb +32 -0
  27. data/lib/dcm_dict/source_data/data_elements_data.rb +4945 -0
  28. data/lib/dcm_dict/source_data/detached_data.rb +67 -0
  29. data/lib/dcm_dict/source_data/uid_values_data.rb +467 -0
  30. data/lib/dcm_dict/version.rb +27 -0
  31. data/lib/dcm_dict/xml/constant.rb +38 -0
  32. data/lib/dcm_dict/xml/field_data.rb +47 -0
  33. data/lib/dcm_dict/xml/nokogiri_tool.rb +108 -0
  34. data/lib/dcm_dict/xml/rexml_tool.rb +105 -0
  35. data/lib/dcm_dict/xml/tag_field_data.rb +96 -0
  36. data/lib/dcm_dict/xml/uid_field_data.rb +60 -0
  37. data/lib/dcm_dict/xml/xml_tool.rb +47 -0
  38. data/spec/data_element_sample_spec_helper.rb +203 -0
  39. data/spec/data_element_shared_example_spec_helper.rb +57 -0
  40. data/spec/dcm_dict/dictionary/data_element_dictionary_spec.rb +76 -0
  41. data/spec/dcm_dict/dictionary/data_element_record_spec.rb +138 -0
  42. data/spec/dcm_dict/dictionary/uid_dictionary_spec.rb +82 -0
  43. data/spec/dcm_dict/dictionary/uid_record_spec.rb +53 -0
  44. data/spec/dcm_dict/encoder/data_to_code_spec.rb +109 -0
  45. data/spec/dcm_dict/ext/object_extension_spec.rb +53 -0
  46. data/spec/dcm_dict/refine/array_refine_spec.rb +60 -0
  47. data/spec/dcm_dict/refine/internal/array_refine_internal_spec.rb +98 -0
  48. data/spec/dcm_dict/refine/internal/hash_refine_internal_spec.rb +64 -0
  49. data/spec/dcm_dict/refine/internal/string_refine_internal_spec.rb +228 -0
  50. data/spec/dcm_dict/refine/string_refine_spec.rb +87 -0
  51. data/spec/dcm_dict/refine/symbol_refine_spec.rb +41 -0
  52. data/spec/dcm_dict/rubies/rb_ext_spec.rb +46 -0
  53. data/spec/dcm_dict/source_data/data_elements_data_spec.rb +40 -0
  54. data/spec/dcm_dict/source_data/detached_data_spec.rb +55 -0
  55. data/spec/dcm_dict/source_data/uid_values_data_spec.rb +37 -0
  56. data/spec/dcm_dict/version_spec.rb +30 -0
  57. data/spec/dcm_dict/xml/tag_field_data_spec.rb +62 -0
  58. data/spec/dcm_dict/xml/uid_field_data_spec.rb +60 -0
  59. data/spec/dictionary_shared_example_spec_helper.rb +118 -0
  60. data/spec/refine_shared_example_spec_helper.rb +54 -0
  61. data/spec/spec_helper.rb +42 -0
  62. data/spec/xml_sample_spec_helper.rb +567 -0
  63. metadata +216 -0
@@ -0,0 +1,64 @@
1
+ #
2
+ # Copyright (C) 2014-2020 Enrico Rivarola
3
+ #
4
+ # This file is part of DcmDict gem (dcm_dict).
5
+ #
6
+ # DcmDict is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # DcmDict is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+ # This software has neither been tested nor approved for clinical use
20
+ # or for incorporation in a medical device.
21
+ # It is the redistributor's or user's responsibility to comply with any
22
+ # applicable local, state, national or international regulations.
23
+ #
24
+ require 'spec_helper'
25
+
26
+ describe "Hash internal refinement" do
27
+ using DcmDict::Refine::Internal::HashRefineInternal
28
+
29
+ it "should check for lowercase tag_ps field" do
30
+ h = {tag_ps: '(fffe,E000)'}
31
+ h.check_tag_ps!
32
+ expect(h).to eq({tag_ps: '(FFFE,E000)'})
33
+ end
34
+
35
+ it "should check for missing tag_ps field" do
36
+ expect{ {tag_ps: ''}.check_tag_ps! }.to raise_error("Missing tag_ps field")
37
+ expect{ {}.check_tag_ps! }.to raise_error("Missing tag_ps field")
38
+ end
39
+
40
+ context "Placeholders data: no Name or Keyword or VR or VM is specified" do
41
+ {
42
+ { tag_ps: '(0018,9445)', tag_name: '', tag_key: '', tag_vr: [], tag_vm: [], tag_note: 'RET - See Note' } => { tag_ps: '(0018,9445)', tag_name: "Placeholder (0018,9445)", tag_key: 'Placeholder_0018_9445', tag_vr: [:UN], tag_vm: ["1"], tag_note: 'RET - See Note'},
43
+ { tag_ps: '(0018,9445)', tag_name: '', tag_key: '', tag_vm: [], tag_note: 'RET - See Note' } => { tag_ps: '(0018,9445)', tag_name: "Placeholder (0018,9445)", tag_key: 'Placeholder_0018_9445', tag_vr: [:UN], tag_vm: ["1"], tag_note: 'RET - See Note'},
44
+ { tag_ps: '(0018,9445)', tag_name: '', tag_key: '', tag_vr: [], tag_note: 'RET - See Note' } => { tag_ps: '(0018,9445)', tag_name: "Placeholder (0018,9445)", tag_key: 'Placeholder_0018_9445', tag_vr: [:UN], tag_vm: ["1"], tag_note: 'RET - See Note'},
45
+ { tag_ps: '(0018,9445)', tag_key: '', tag_vr: [], tag_vm: [], tag_note: 'RET - See Note' } => { tag_ps: '(0018,9445)', tag_name: "Placeholder (0018,9445)", tag_key: 'Placeholder_0018_9445', tag_vr: [:UN], tag_vm: ["1"], tag_note: 'RET - See Note'},
46
+ { tag_ps: '(0018,9445)', tag_name: '', tag_vr: [], tag_vm: [], tag_note: 'RET - See Note' } => { tag_ps: '(0018,9445)', tag_name: "Placeholder (0018,9445)", tag_key: 'Placeholder_0018_9445', tag_vr: [:UN], tag_vm: ["1"], tag_note: 'RET - See Note'},
47
+ }.each do |src_data, expected_data|
48
+ it "should check for placeholder data (#{src_data[:tag_ps].inspect} with keys #{src_data.keys.inspect})" do
49
+ src_data.check_placeholder_data!
50
+ expect(src_data).to eq(expected_data)
51
+ end
52
+ end
53
+
54
+ [
55
+ { tag_ps: '', tag_name: '', tag_key: '', tag_vr: [], tag_vm: [], tag_note: 'RET - See Note' },
56
+ { tag_name: '', tag_key: '', tag_vr: [], tag_vm: [], tag_note: 'RET - See Note' }
57
+ ].each do |data|
58
+ it "should raise error if :tag_ps field is missing (tag_ps=#{data[:tag_ps].inspect})" do
59
+ expect{data.check_placeholder_data!}.to raise_error("Missing tag_ps field")
60
+ end
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,228 @@
1
+ # coding: utf-8
2
+ #
3
+ # Copyright (C) 2014-2020 Enrico Rivarola
4
+ #
5
+ # This file is part of DcmDict gem (dcm_dict).
6
+ #
7
+ # DcmDict is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # DcmDict is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
19
+ #
20
+ # This software has neither been tested nor approved for clinical use
21
+ # or for incorporation in a medical device.
22
+ # It is the redistributor's or user's responsibility to comply with any
23
+ # applicable local, state, national or international regulations.
24
+ #
25
+ require 'spec_helper'
26
+
27
+ describe "String refinement (internal)" do
28
+
29
+ using DcmDict::Refine::Internal::StringRefineInternal
30
+ describe "should remove unwanted space characters" do
31
+
32
+ [
33
+ ["FileSetDescriptorFileID ", "trailing spaces"],
34
+ [" FileSetDescriptorFileID", "leading spaces"],
35
+ [" FileSetDescriptorFileID ", "leading and trailing spaces"],
36
+ ["File​Set​Descriptor​FileID", "zero width spaces"],
37
+ [" File​Set​Descriptor​FileID ", "leading, trailing and zero width spaces"]
38
+ ].each do |wrong_string, comment|
39
+ it "for string containing #{comment}" do
40
+ expect(wrong_string.dcm_unspace).to eq('FileSetDescriptorFileID')
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "should convert keyword tag string to symbol object" do
46
+ [
47
+ ['DarkCurrentCounts', :dark_current_counts],
48
+ ['InstanceCreationDate', :instance_creation_date],
49
+ ['RecognitionCode', :recognition_code],
50
+ ['CoefficientsSDVN', :coefficients_sdvn],
51
+ ['OffsetOfReferencedLowerLevelDirectoryEntity', :offset_of_referenced_lower_level_directory_entity],
52
+ ['FileSetDescriptorFileID', :file_set_descriptor_file_id],
53
+ ['SOPClassUID', :sop_class_uid],
54
+ ['RelatedGeneralSOPClassUID', :related_general_sop_class_uid],
55
+ ['ReferencedSOPClassUIDInFile', :referenced_sop_class_uid_in_file],
56
+ ['MAUsedInGainCalibration', :ma_used_in_gain_calibration],
57
+ ['OtherPatientIDsSequence', :other_patient_ids_sequence],
58
+ ['RelativeXRayExposure', :relative_x_ray_exposure],
59
+ ['DisplayedZValue', :displayed_z_value],
60
+ ['PhysicalUnitsXDirection', :physical_units_x_direction],
61
+ ['XRay3DFrameTypeSequence', :x_ray_3d_frame_type_sequence],
62
+ ['SOPInstanceUIDOfConcatenationSource', :sop_instance_uid_of_concatenation_source],
63
+ ['RowsForNthOrderCoefficients', :rows_for_nth_order_coefficients],
64
+ ['EquivalentCDADocumentSequence', :equivalent_cda_document_sequence],
65
+ ['ALineRate', :a_line_rate],
66
+ ['ThreeDPointCoordinates', :three_d_point_coordinates],
67
+ ['SourceImageIDs', :source_image_ids],
68
+ ['ModifyingDeviceID', :modifying_device_id],
69
+ ['TIDOffset', :tid_offset],
70
+ ['RT_ROIRelationship', :rt_roi_relationship],
71
+ ['DVHROIContributionType', :dvh_roi_contribution_type],
72
+ ['OCTZOffsetCorrection', :oct_z_offset_correction],
73
+ ['WADORSRetrievalSequence', :wado_rs_retrieval_sequence],
74
+ ['STOWRSStorageSequence', :stow_rs_storage_sequence],
75
+ ['CIExyWhitePoint', :ciexy_white_point],
76
+ ['RGBLUTTransferFunction', :rgb_lut_transfer_function],
77
+ ['ReferencedVOILUTBoxSequence', :referenced_voi_lut_box_sequence],
78
+ ['CTDIvolNotificationTrigger', :ctdi_vol_notification_trigger],
79
+ ['XAXRFFrameCharacteristicsSequence', :xa_xrf_frame_characteristics_sequence],
80
+ ['XRayTubeCurrentInuA', :x_ray_tube_current_in_ua],
81
+ ['ExposureTimeInuS', :exposure_time_in_us],
82
+ ['ExposureInuAs', :exposure_in_uas],
83
+ ['dBdt', :db_dt]
84
+ ].each do |str, value|
85
+ it "from #{str.inspect} to #{value.inspect}" do
86
+ expect(str.tag_key_to_sym).to eq(value)
87
+ end
88
+ end
89
+ end
90
+
91
+ describe "should convert standard string tag" do
92
+ [
93
+ ['(0014,3050)', '00143050', [0x0014,0x3050]],
94
+ ['(0008,0012)', '00080012', [0x0008,0x0012]],
95
+ ['(FFFE,E00D)', 'FFFEE00D', [0xfffe,0xe00d]]
96
+ ].each do |str, value_str, value_ary|
97
+ it "from #{str.inspect} to a numeric string tag as #{value_str.inspect}" do
98
+ expect(str.to_tag_ndm).to eq(value_str)
99
+ end
100
+
101
+ it "from #{str.inspect} to an array object as #{value_ary.inspect}" do
102
+ expect(str.to_tag_ary).to eq(value_ary)
103
+ end
104
+ end
105
+ end
106
+
107
+ {
108
+ '(0010,0020)'=> [0x0010,0x0020],
109
+ '00100020' => [0x0010,0x0020]
110
+
111
+ }.each do |src, expected_val|
112
+ it "should implement to_tag_ary metod" do
113
+ expect(src.to_tag_ary).to eq(expected_val)
114
+ end
115
+ end
116
+
117
+ {
118
+ '(0010,0020)'=> '(0010,0020)',
119
+ '00100020' => '(0010,0020)'
120
+
121
+ }.each do |src, expected_val|
122
+ it "should implement to_tag_str method" do
123
+ expect(src.to_tag_str).to eq(expected_val)
124
+ end
125
+ end
126
+
127
+ {
128
+ '(0010,0020)'=> [0x0010,0x0020],
129
+ '00100020' => [0x0010,0x0020]
130
+
131
+ }.each do |src, expected_val|
132
+ it "should implement tag_group_num and tag_element_num method" do
133
+ expect(src.tag_group_num).to eq(expected_val[0])
134
+ expect(src.tag_element_num).to eq(expected_val[1])
135
+ end
136
+ end
137
+
138
+ {
139
+ '(0010,0020)'=> ['0010','0020'],
140
+ '00100020' => ['0010','0020'],
141
+ '(FFFE,E000)'=> ['FFFE','E000'],
142
+
143
+ }.each do |src, expected_val|
144
+ it "should implement tag_group_str and tag_element_str method" do
145
+ expect(src.tag_group_str).to eq(expected_val[0])
146
+ expect(src.tag_element_str).to eq(expected_val[1])
147
+ end
148
+ end
149
+
150
+ [
151
+ '(0010,00208)',
152
+ 'abracadabra',
153
+ Time.now.to_s,
154
+ '(1ffff,123)',
155
+ '(123,1fff0)'
156
+ ].each do |src|
157
+ it "should manage wrong value #{src.inspect}" do
158
+ expect{src.to_tag_str}.to raise_error(RuntimeError)
159
+ expect{src.to_tag_ndm}.to raise_error(RuntimeError)
160
+ expect{src.to_tag_ary}.to raise_error(RuntimeError)
161
+ end
162
+ end
163
+
164
+ {
165
+ 'SOP Class' => :sop_class,
166
+ 'Transfer Syntax' => :transfer_syntax,
167
+ 'Well-known frame of reference' => :well_known_frame_of_reference,
168
+ 'Well-known SOP Instance' => :well_known_sop_instance,
169
+ 'DICOM UIDs as a Coding Scheme' => :dicom_uids_as_a_coding_scheme,
170
+ 'Coding Scheme' => :coding_scheme,
171
+ 'Query/Retrieve' => :query_retrieve,
172
+ 'LDAP OID' => :ldap_oid
173
+
174
+
175
+ }.each do |src, expected_val|
176
+ it "should implement uid_type_to_sym method #{src.inspect} > #{expected_val.inspect}" do
177
+ expect(src.uid_type_to_sym).to eq(expected_val)
178
+ end
179
+ end
180
+
181
+ {
182
+ '1.2.3.4.5.6' => true,
183
+ 'not uid string' => false,
184
+ '0.1.2.3.4' => true,
185
+ '1.2.3456.789.0.1.2.3' => true,
186
+ '1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3' => false,
187
+ '1,2.3' => false,
188
+ '1.2.3.04.5' => false
189
+ }.each do |string, expected_as_uid|
190
+ it "should check for UID string #{string.inspect} -> #{expected_as_uid}" do
191
+ expect(string.uid_value?).to eq(expected_as_uid)
192
+ end
193
+ end
194
+
195
+ describe "should check for group-length tag" do
196
+ {
197
+ "00100020" => false,
198
+ "(0010,0020)" => false,
199
+ "00100000" => true,
200
+ "(0010,0000)" => true,
201
+ "00000002" => false,
202
+ "(0000,0002)" => false,
203
+ "00000000" => true,
204
+ "(0000,0000)" => true
205
+ }.each do |tag, value|
206
+ it "for #{tag.inspect}" do
207
+ expect(tag.group_length_tag?).to eq(value)
208
+ end
209
+ end
210
+ end
211
+
212
+ describe "should check for private-creator tag" do
213
+ {
214
+ '00100010' => false,
215
+ '(0010,0010)' => false,
216
+ '00110010' => true,
217
+ '(0011,0010)' => true,
218
+ '00110110' => false,
219
+ '(0011,0110)' => false,
220
+ '00282468' => false,
221
+ '(0028,2468)' => false
222
+ }.each do |tag, value|
223
+ it "for #{tag.inspect}" do
224
+ expect(tag.private_creator_tag?).to eq(value)
225
+ end
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,87 @@
1
+ #
2
+ # Copyright (C) 2014-2020 Enrico Rivarola
3
+ #
4
+ # This file is part of DcmDict gem (dcm_dict).
5
+ #
6
+ # DcmDict is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # DcmDict is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+ # This software has neither been tested nor approved for clinical use
20
+ # or for incorporation in a medical device.
21
+ # It is the redistributor's or user's responsibility to comply with any
22
+ # applicable local, state, national or international regulations.
23
+ #
24
+ require 'spec_helper'
25
+
26
+ describe "String refinement" do
27
+ using DcmDict::Refine::StringRefine
28
+ describe "should permit access to single data element dictionary information" do
29
+
30
+ include_examples "refinement for standard tag",
31
+ ["(0010,1005)", "Patient's Birth Name", "PatientBirthName", "(0010,1005)", "00101005",
32
+ '(60XX,0040)', "Overlay Type", "OverlayType", "(6022,0040)", "60220040",
33
+ '(0028,1200)', "Gray Lookup Table Data", "GrayLookupTableData", "(0028,1200)", "00281200",
34
+ '(0014,3050)', "Dark Current Counts", "DarkCurrentCounts", "(0014,3050)", "00143050",
35
+ ],
36
+ Proc.new{|tag| tag.inspect}
37
+
38
+
39
+ multi_str_data = { '(6046,0040)' => {
40
+ tag_multiple: true,
41
+ tag_name: "Overlay Type",
42
+ tag_keyword: "OverlayType",
43
+ tag_key: "OverlayType",
44
+ tag_vr: [:CS], tag_vm: ["1"],
45
+ tag: [0x6046, 0x0040], tag_ary: [0x6046, 0x0040],
46
+ tag_ps: "(60XX,0040)",
47
+ tag_sym: :overlay_type,
48
+ tag_ndm: "60460040",
49
+ tag_str: "(6046,0040)",
50
+ tag_group: 0x6046,
51
+ tag_element: 0x0040 } }
52
+
53
+ include_examples "refinement for multiple tag",
54
+ multi_str_data,
55
+ Proc.new {|tag| tag.inspect}
56
+
57
+ end
58
+
59
+
60
+ describe "should permit access to single data uid dictionary information" do
61
+ describe "for regular uids" do
62
+ [
63
+ '1.2.840.10008.1.1', "Verification SOP Class",
64
+ '1.2.840.10008.1.2.1', "Explicit VR Little Endian",
65
+ '1.2.840.10008.5.1.4.1.2.1.1', "Patient Root Query/Retrieve Information Model - FIND",
66
+ '1.2.3.4.5.6'
67
+ ].each do |uid|
68
+ describe "as #{uid.inspect}" do
69
+ obj = DcmDict::Dictionary::TheUidDictionary.record_at(uid)
70
+ DcmDict::Dictionary::UidMethod.each do |method|
71
+ expr = "#{uid.inspect}.#{method.to_s}"
72
+ it "with #{expr} > #{obj.send(method).inspect}" do
73
+ value = eval(expr)
74
+ expect(value).to eq(obj.send(method))
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ include_examples "Raise exception for wrong input",
83
+ [ '123g123m' ],
84
+ [ 'this string is not an uid' ],
85
+ Proc.new {|tag| tag.inspect}
86
+
87
+ end
@@ -0,0 +1,41 @@
1
+ #
2
+ # Copyright (C) 2014-2020 Enrico Rivarola
3
+ #
4
+ # This file is part of DcmDict gem (dcm_dict).
5
+ #
6
+ # DcmDict is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # DcmDict is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+ # This software has neither been tested nor approved for clinical use
20
+ # or for incorporation in a medical device.
21
+ # It is the redistributor's or user's responsibility to comply with any
22
+ # applicable local, state, national or international regulations.
23
+ #
24
+ require 'spec_helper'
25
+
26
+ describe "Symbol refinement" do
27
+ using DcmDict::Refine::SymbolRefine
28
+ describe "should permit access to single data element dictionary information" do
29
+
30
+ include_examples "refinement for standard tag",
31
+ [:patient_birth_name, :gray_lookup_table_data, :dark_current_counts],
32
+ Proc.new{|tag| tag.inspect}
33
+
34
+ end
35
+
36
+ include_examples "Raise exception for wrong input",
37
+ [ :wrong_data_element ],
38
+ [],
39
+ Proc.new {|tag| tag.inspect}
40
+
41
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Copyright (C) 2014-2020 Enrico Rivarola
3
+ #
4
+ # This file is part of DcmDict gem (dcm_dict).
5
+ #
6
+ # DcmDict is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # DcmDict is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+ # This software has neither been tested nor approved for clinical use
20
+ # or for incorporation in a medical device.
21
+ # It is the redistributor's or user's responsibility to comply with any
22
+ # applicable local, state, national or international regulations.
23
+ #
24
+ require 'spec_helper'
25
+
26
+ describe "Rubies dedicate extension" do
27
+ it "should check for Fixnum::bit_length method" do
28
+ {(-2**12-1) => 13,
29
+ (-2**12) => 12,
30
+ (-2**12+1) => 12,
31
+ -0x101 => 9,
32
+ -0x100 => 8,
33
+ -0xff => 8,
34
+ -2 => 1,
35
+ -1 => 0,
36
+ 0 => 0,
37
+ 1 => 1,
38
+ 0xff => 8,
39
+ 0x100 => 9,
40
+ (2**12-1) => 12,
41
+ (2**12) => 13,
42
+ (2**12+1) => 13}.each do |num, expected_bit_length|
43
+ expect(num.bit_length).to eq(expected_bit_length)
44
+ end
45
+ end
46
+ end