cosmos 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (364) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +195 -0
  3. data/README.md +3 -3
  4. data/data/crc.txt +52 -52
  5. data/lib/cosmos.rb +1 -1
  6. data/lib/cosmos/core_ext/time.rb +11 -9
  7. data/lib/cosmos/gui/choosers/telemetry_chooser.rb +0 -2
  8. data/lib/cosmos/gui/dialogs/about_dialog.rb +2 -2
  9. data/lib/cosmos/gui/dialogs/exception_dialog.rb +2 -2
  10. data/lib/cosmos/gui/dialogs/progress_dialog.rb +11 -5
  11. data/lib/cosmos/gui/dialogs/splash.rb +32 -10
  12. data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +1 -1
  13. data/lib/cosmos/gui/line_graph/line_graph_drawing.rb +2 -2
  14. data/lib/cosmos/gui/qt.rb +22 -22
  15. data/lib/cosmos/io/json_drb.rb +4 -4
  16. data/lib/cosmos/io/json_rpc.rb +21 -21
  17. data/lib/cosmos/packet_logs/packet_log_writer.rb +18 -20
  18. data/lib/cosmos/packets/commands.rb +8 -6
  19. data/lib/cosmos/packets/limits.rb +3 -2
  20. data/lib/cosmos/packets/packet.rb +14 -11
  21. data/lib/cosmos/packets/parsers/limits_parser.rb +1 -1
  22. data/lib/cosmos/packets/parsers/macro_parser.rb +4 -4
  23. data/lib/cosmos/packets/parsers/state_parser.rb +1 -1
  24. data/lib/cosmos/packets/structure.rb +2 -2
  25. data/lib/cosmos/packets/telemetry.rb +5 -4
  26. data/lib/cosmos/script/script.rb +6 -6
  27. data/lib/cosmos/streams/tcpip_socket_stream.rb +2 -1
  28. data/lib/cosmos/streams/template_stream_protocol.rb +1 -1
  29. data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +1 -1
  30. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +5 -8
  31. data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +4 -3
  32. data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +9 -3
  33. data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +15 -11
  34. data/lib/cosmos/tools/data_viewer/data_viewer.rb +1 -1
  35. data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +2 -2
  36. data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +2 -2
  37. data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +0 -2
  38. data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +1 -1
  39. data/lib/cosmos/tools/replay/replay.rb +2 -2
  40. data/lib/cosmos/tools/script_runner/script_audit.rb +1 -1
  41. data/lib/cosmos/tools/script_runner/script_runner.rb +1 -1
  42. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +3 -7
  43. data/lib/cosmos/tools/table_manager/table_config.rb +1 -1
  44. data/lib/cosmos/tools/test_runner/results_writer.rb +1 -1
  45. data/lib/cosmos/tools/test_runner/test_runner.rb +2 -2
  46. data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +2 -1
  47. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +1 -1
  48. data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +1 -0
  49. data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +1 -0
  50. data/lib/cosmos/tools/tlm_grapher/data_object_editors/xy_data_object_editor.rb +1 -0
  51. data/lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb +3 -3
  52. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +1 -3
  53. data/lib/cosmos/top_level.rb +2 -6
  54. data/lib/cosmos/utilities/ruby_lex_utils.rb +1 -1
  55. data/lib/cosmos/version.rb +5 -5
  56. data/lib/cosmos/win32/win32_main.rb +11 -7
  57. data/spec/ccsds/ccsds_packet_spec.rb +28 -28
  58. data/spec/ccsds/ccsds_parser_spec.rb +27 -27
  59. data/spec/config/config_parser_spec.rb +88 -88
  60. data/spec/conversions/conversion_spec.rb +3 -3
  61. data/spec/conversions/generic_conversion_spec.rb +9 -9
  62. data/spec/conversions/new_packet_log_conversion_spec.rb +4 -4
  63. data/spec/conversions/polynomial_conversion_spec.rb +7 -7
  64. data/spec/conversions/processor_conversion_spec.rb +9 -9
  65. data/spec/conversions/received_count_conversion_spec.rb +7 -7
  66. data/spec/conversions/received_time_formatted_conversion_spec.rb +9 -9
  67. data/spec/conversions/received_time_seconds_conversion_spec.rb +9 -9
  68. data/spec/conversions/segmented_polynomial_conversion_spec.rb +11 -11
  69. data/spec/conversions/unix_time_formatted_conversion_spec.rb +13 -13
  70. data/spec/conversions/unix_time_seconds_conversion_spec.rb +13 -13
  71. data/spec/core_ext/array_spec.rb +76 -76
  72. data/spec/core_ext/class_spec.rb +3 -3
  73. data/spec/core_ext/cosmos_io_spec.rb +16 -16
  74. data/spec/core_ext/exception_spec.rb +19 -19
  75. data/spec/core_ext/file_spec.rb +16 -16
  76. data/spec/core_ext/hash_spec.rb +3 -3
  77. data/spec/core_ext/io_spec.rb +2 -2
  78. data/spec/core_ext/kernel_spec.rb +2 -2
  79. data/spec/core_ext/math_spec.rb +43 -43
  80. data/spec/core_ext/matrix_spec.rb +22 -22
  81. data/spec/core_ext/objectspace_spec.rb +6 -6
  82. data/spec/core_ext/range_spec.rb +2 -2
  83. data/spec/core_ext/socket_spec.rb +4 -4
  84. data/spec/core_ext/string_spec.rb +67 -67
  85. data/spec/core_ext/stringio_spec.rb +2 -2
  86. data/spec/core_ext/time_spec.rb +82 -82
  87. data/spec/gui/line_graph/line_clip_spec.rb +34 -34
  88. data/spec/interfaces/interface_spec.rb +46 -46
  89. data/spec/interfaces/linc_interface_spec.rb +26 -26
  90. data/spec/interfaces/serial_interface_spec.rb +16 -16
  91. data/spec/interfaces/simulated_target_interface_spec.rb +21 -21
  92. data/spec/interfaces/stream_interface_spec.rb +22 -22
  93. data/spec/interfaces/tcpip_client_interface_spec.rb +14 -14
  94. data/spec/interfaces/tcpip_server_interface_spec.rb +41 -41
  95. data/spec/interfaces/udp_interface_spec.rb +46 -46
  96. data/spec/io/buffered_file_spec.rb +50 -50
  97. data/spec/io/io_multiplexer_spec.rb +9 -9
  98. data/spec/io/json_drb_object_spec.rb +7 -7
  99. data/spec/io/json_drb_spec.rb +55 -55
  100. data/spec/io/json_rpc_spec.rb +68 -68
  101. data/spec/io/raw_logger_pair_spec.rb +28 -28
  102. data/spec/io/raw_logger_spec.rb +22 -22
  103. data/spec/io/serial_driver_spec.rb +3 -3
  104. data/spec/io/stderr_spec.rb +2 -2
  105. data/spec/io/stdout_spec.rb +2 -2
  106. data/spec/io/tcpip_server_spec.rb +62 -62
  107. data/spec/io/udp_sockets_spec.rb +19 -19
  108. data/spec/io/win32_serial_driver_spec.rb +10 -10
  109. data/spec/packet_logs/meta_packet_log_writer_spec.rb +32 -32
  110. data/spec/packet_logs/packet_log_reader_spec.rb +138 -138
  111. data/spec/packet_logs/packet_log_writer_pair_spec.rb +3 -3
  112. data/spec/packet_logs/packet_log_writer_spec.rb +26 -26
  113. data/spec/packets/binary_accessor_spec.rb +672 -672
  114. data/spec/packets/commands_spec.rb +123 -123
  115. data/spec/packets/limits_response_spec.rb +1 -1
  116. data/spec/packets/limits_spec.rb +69 -69
  117. data/spec/packets/packet_config_spec.rb +93 -93
  118. data/spec/packets/packet_item_limits_spec.rb +46 -46
  119. data/spec/packets/packet_item_spec.rb +108 -108
  120. data/spec/packets/packet_spec.rb +364 -348
  121. data/spec/packets/parsers/format_string_parser_spec.rb +13 -13
  122. data/spec/packets/parsers/limits_parser_spec.rb +8 -8
  123. data/spec/packets/parsers/limits_response_parser_spec.rb +9 -9
  124. data/spec/packets/parsers/macro_parser_spec.rb +34 -6
  125. data/spec/packets/parsers/packet_parser_spec.rb +6 -6
  126. data/spec/packets/parsers/processor_parser_spec.rb +7 -7
  127. data/spec/packets/parsers/state_parser_spec.rb +23 -23
  128. data/spec/packets/structure_item_spec.rb +62 -62
  129. data/spec/packets/structure_spec.rb +183 -183
  130. data/spec/packets/telemetry_spec.rb +174 -174
  131. data/spec/processors/new_packet_log_processor_spec.rb +4 -4
  132. data/spec/processors/processor_spec.rb +9 -9
  133. data/spec/processors/statistics_processor_spec.rb +21 -21
  134. data/spec/processors/watermark_processor_spec.rb +12 -12
  135. data/spec/script/script_spec.rb +158 -158
  136. data/spec/spec_helper.rb +44 -13
  137. data/spec/streams/burst_stream_protocol_spec.rb +8 -8
  138. data/spec/streams/fixed_stream_protocol_spec.rb +26 -26
  139. data/spec/streams/length_stream_protocol_spec.rb +27 -27
  140. data/spec/streams/preidentified_stream_protocol_spec.rb +25 -25
  141. data/spec/streams/serial_stream_spec.rb +19 -19
  142. data/spec/streams/stream_protocol_spec.rb +52 -52
  143. data/spec/streams/stream_spec.rb +1 -1
  144. data/spec/streams/tcpip_client_stream_spec.rb +7 -7
  145. data/spec/streams/tcpip_socket_stream_spec.rb +84 -49
  146. data/spec/streams/template_stream_protocol_spec.rb +17 -17
  147. data/spec/streams/terminated_stream_protocol_spec.rb +19 -19
  148. data/spec/system/system_spec.rb +95 -95
  149. data/spec/system/target_spec.rb +32 -32
  150. data/spec/tools/cmd_tlm_server/api_spec.rb +386 -386
  151. data/spec/tools/cmd_tlm_server/background_task_spec.rb +3 -3
  152. data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +8 -8
  153. data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +57 -57
  154. data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +85 -85
  155. data/spec/tools/cmd_tlm_server/commanding_spec.rb +11 -11
  156. data/spec/tools/cmd_tlm_server/connections_spec.rb +23 -23
  157. data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +57 -57
  158. data/spec/tools/cmd_tlm_server/interfaces_spec.rb +32 -32
  159. data/spec/tools/cmd_tlm_server/packet_logging_spec.rb +17 -17
  160. data/spec/tools/cmd_tlm_server/router_thread_spec.rb +15 -15
  161. data/spec/tools/cmd_tlm_server/routers_spec.rb +36 -36
  162. data/spec/top_level/top_level_spec.rb +60 -60
  163. data/spec/utilities/crc_spec.rb +6 -6
  164. data/spec/utilities/csv_spec.rb +13 -13
  165. data/spec/utilities/logger_spec.rb +20 -20
  166. data/spec/utilities/message_log_spec.rb +13 -13
  167. data/spec/utilities/quaternion_spec.rb +30 -30
  168. data/spec/utilities/ruby_lex_utils_spec.rb +14 -14
  169. data/test/benchmarks/binary_accessor_benchmark.rb +14 -0
  170. data/test/benchmarks/gsub_benchmark.rb +114 -0
  171. data/test/performance/PACKETS.bat +1 -0
  172. data/test/performance/Rakefile +77 -0
  173. data/test/performance/THREADS.bat +1 -0
  174. data/test/performance/config/data/attitude.bin +0 -0
  175. data/test/performance/config/data/crc.txt +206 -0
  176. data/test/performance/config/data/diamond.STL +58 -0
  177. data/test/performance/config/data/groundoff.gif +0 -0
  178. data/test/performance/config/data/groundon.gif +0 -0
  179. data/test/performance/config/data/hselectoff.gif +0 -0
  180. data/test/performance/config/data/hselecton.gif +0 -0
  181. data/test/performance/config/data/hswitchoff.gif +0 -0
  182. data/test/performance/config/data/hswitchon.gif +0 -0
  183. data/test/performance/config/data/meta_init.txt +4 -0
  184. data/test/performance/config/data/position.bin +0 -0
  185. data/test/performance/config/data/poweroff.gif +0 -0
  186. data/test/performance/config/data/poweron.gif +0 -0
  187. data/test/performance/config/data/satellite.gif +0 -0
  188. data/test/performance/config/data/tada.wav +0 -0
  189. data/test/performance/config/data/vswitchoff.gif +0 -0
  190. data/test/performance/config/data/vswitchon.gif +0 -0
  191. data/test/performance/config/system/system_packets.txt +39 -0
  192. data/test/performance/config/system/system_threads.txt +59 -0
  193. data/test/performance/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +41 -0
  194. data/test/performance/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +15 -0
  195. data/test/performance/config/targets/COSMOS/cmd_tlm_server.txt +6 -0
  196. data/test/performance/config/targets/COSMOS/screens/limits_change.txt +20 -0
  197. data/test/performance/config/targets/COSMOS/screens/version.txt +19 -0
  198. data/test/performance/config/targets/COSMOS/target.txt +11 -0
  199. data/test/performance/config/targets/EXAMPLE/cmd_tlm/example_cmds.txt +17 -0
  200. data/test/performance/config/targets/EXAMPLE/cmd_tlm/example_tlm.txt +18 -0
  201. data/test/performance/config/targets/EXAMPLE/cmd_tlm_server.txt +6 -0
  202. data/test/performance/config/targets/EXAMPLE/lib/example_interface.rb +22 -0
  203. data/test/performance/config/targets/EXAMPLE/target.txt +7 -0
  204. data/test/performance/config/targets/SYSTEM/screens/status.txt +12 -0
  205. data/test/performance/config/tools/cmd_tlm_server/cmd_tlm_server_packets.txt +34 -0
  206. data/test/performance/config/tools/cmd_tlm_server/cmd_tlm_server_threads.txt +68 -0
  207. data/test/performance/config/tools/data_viewer/data_viewer.txt +11 -0
  208. data/test/performance/config/tools/handbook_creator/default_toc.xsl +59 -0
  209. data/test/performance/config/tools/handbook_creator/handbook_creator.txt +66 -0
  210. data/test/performance/config/tools/handbook_creator/templates/command_packets.html.erb +86 -0
  211. data/test/performance/config/tools/handbook_creator/templates/command_toc.html.erb +38 -0
  212. data/test/performance/config/tools/handbook_creator/templates/footer.html.erb +9 -0
  213. data/test/performance/config/tools/handbook_creator/templates/header.html.erb +25 -0
  214. data/test/performance/config/tools/handbook_creator/templates/limits_groups.html.erb +13 -0
  215. data/test/performance/config/tools/handbook_creator/templates/nav.html.erb +27 -0
  216. data/test/performance/config/tools/handbook_creator/templates/overview.html.erb +1 -0
  217. data/test/performance/config/tools/handbook_creator/templates/pdf_cover.html.erb +23 -0
  218. data/test/performance/config/tools/handbook_creator/templates/pdf_footer.html.erb +33 -0
  219. data/test/performance/config/tools/handbook_creator/templates/pdf_header.html.erb +41 -0
  220. data/test/performance/config/tools/handbook_creator/templates/telemetry_packets.html.erb +80 -0
  221. data/test/performance/config/tools/handbook_creator/templates/telemetry_toc.html.erb +38 -0
  222. data/test/performance/config/tools/handbook_creator/templates/title.html.erb +1 -0
  223. data/test/performance/config/tools/launcher/launcher_packets.txt +29 -0
  224. data/test/performance/config/tools/launcher/launcher_threads.txt +70 -0
  225. data/test/performance/config/tools/limits_monitor/README.txt +1 -0
  226. data/test/performance/config/tools/opengl_builder/README.txt +1 -0
  227. data/test/performance/config/tools/script_runner/script_runner.txt +3 -0
  228. data/test/performance/config/tools/table_manager/ConfigTables_def.txt +8 -0
  229. data/test/performance/config/tools/table_manager/ExampleTableDefinition.txt +24 -0
  230. data/test/performance/config/tools/table_manager/MCConfigurationTable_fsw1_def.txt +25 -0
  231. data/test/performance/config/tools/table_manager/MCConfigurationTable_fsw2_def.txt +25 -0
  232. data/test/performance/config/tools/table_manager/PPSSelectionTable_def.txt +8 -0
  233. data/test/performance/config/tools/table_manager/TLMMonitoringTable_def.txt +248 -0
  234. data/test/performance/config/tools/test_runner/test_runner.txt +17 -0
  235. data/test/performance/config/tools/tlm_extractor/tlm_extractor.txt +13 -0
  236. data/test/performance/config/tools/tlm_extractor/tlm_extractor2.txt +2 -0
  237. data/test/performance/config/tools/tlm_extractor/tlm_extractor3.txt +2 -0
  238. data/test/performance/config/tools/tlm_extractor/tlm_extractor4.txt +2 -0
  239. data/test/performance/config/tools/tlm_grapher/README.txt +1 -0
  240. data/test/performance/config/tools/tlm_viewer/tlm_viewer.txt +41 -0
  241. data/test/performance/lib/example_background_task.rb +57 -0
  242. data/test/performance/lib/example_target.rb +120 -0
  243. data/test/performance/lib/scpi_target.rb +74 -0
  244. data/test/performance/lib/user_version.rb +3 -0
  245. data/test/performance/outputs/handbooks/README.txt +1 -0
  246. data/test/performance/outputs/logs/README.txt +1 -0
  247. data/test/performance/outputs/saved_config/README.txt +1 -0
  248. data/test/performance/outputs/tables/README.txt +1 -0
  249. data/test/performance/outputs/tmp/README.txt +1 -0
  250. data/test/performance/procedures/checks.rb +11 -0
  251. data/test/performance/procedures/clear_util.rb +7 -0
  252. data/test/performance/procedures/collect.rb +18 -0
  253. data/test/performance/procedures/collect_util.rb +14 -0
  254. data/test/performance/procedures/cosmos_api_test.rb +293 -0
  255. data/test/performance/procedures/disconnect.rb +29 -0
  256. data/test/performance/procedures/example_test.rb +182 -0
  257. data/test/performance/procedures/plot_test.rb +8 -0
  258. data/test/performance/procedures/procedure.rb +3 -0
  259. data/test/performance/procedures/run_example_test.rb +3 -0
  260. data/test/performance/procedures/test.rb +51 -0
  261. data/test/performance/tools/CmdExtractor +14 -0
  262. data/test/performance/tools/CmdExtractor.bat +59 -0
  263. data/test/performance/tools/CmdSender +14 -0
  264. data/test/performance/tools/CmdSender.bat +59 -0
  265. data/test/performance/tools/CmdTlmServer +16 -0
  266. data/test/performance/tools/CmdTlmServer.bat +59 -0
  267. data/test/performance/tools/CmdTlmServerMemProf +20 -0
  268. data/test/performance/tools/CmdTlmServerMemProf.bat +59 -0
  269. data/test/performance/tools/DataViewer +14 -0
  270. data/test/performance/tools/DataViewer.bat +59 -0
  271. data/test/performance/tools/ExampleTarget +14 -0
  272. data/test/performance/tools/ExampleTarget.bat +59 -0
  273. data/test/performance/tools/HandbookCreator +14 -0
  274. data/test/performance/tools/HandbookCreator.bat +61 -0
  275. data/test/performance/tools/Launcher +14 -0
  276. data/test/performance/tools/Launcher.bat +59 -0
  277. data/test/performance/tools/LimitsMonitor +14 -0
  278. data/test/performance/tools/LimitsMonitor.bat +59 -0
  279. data/test/performance/tools/OpenGLBuilder +14 -0
  280. data/test/performance/tools/OpenGLBuilder.bat +59 -0
  281. data/test/performance/tools/PacketViewer +14 -0
  282. data/test/performance/tools/PacketViewer.bat +59 -0
  283. data/test/performance/tools/Replay +14 -0
  284. data/test/performance/tools/Replay.bat +59 -0
  285. data/test/performance/tools/ScpiTarget +14 -0
  286. data/test/performance/tools/ScpiTarget.bat +59 -0
  287. data/test/performance/tools/ScriptRunner +14 -0
  288. data/test/performance/tools/ScriptRunner.bat +59 -0
  289. data/test/performance/tools/TableManager +14 -0
  290. data/test/performance/tools/TableManager.bat +59 -0
  291. data/test/performance/tools/TestRunner +14 -0
  292. data/test/performance/tools/TestRunner.bat +59 -0
  293. data/test/performance/tools/TlmExtractor +14 -0
  294. data/test/performance/tools/TlmExtractor.bat +59 -0
  295. data/test/performance/tools/TlmGrapher +14 -0
  296. data/test/performance/tools/TlmGrapher.bat +59 -0
  297. data/test/performance/tools/TlmViewer +14 -0
  298. data/test/performance/tools/TlmViewer.bat +59 -0
  299. data/test/performance/tools/mac/CmdExtractor.app/Contents/Info.plist +38 -0
  300. data/test/performance/tools/mac/CmdExtractor.app/Contents/MacOS/CmdExtractor.rb +15 -0
  301. data/test/performance/tools/mac/CmdExtractor.app/Contents/MacOS/main.sh +6 -0
  302. data/test/performance/tools/mac/CmdExtractor.app/Contents/Resources/appIcon.icns +0 -0
  303. data/test/performance/tools/mac/CmdSender.app/Contents/Info.plist +38 -0
  304. data/test/performance/tools/mac/CmdSender.app/Contents/MacOS/CmdSender.rb +15 -0
  305. data/test/performance/tools/mac/CmdSender.app/Contents/MacOS/main.sh +6 -0
  306. data/test/performance/tools/mac/CmdSender.app/Contents/Resources/appIcon.icns +0 -0
  307. data/test/performance/tools/mac/CmdTlmServer.app/Contents/Info.plist +38 -0
  308. data/test/performance/tools/mac/CmdTlmServer.app/Contents/MacOS/CmdTlmServer.rb +15 -0
  309. data/test/performance/tools/mac/CmdTlmServer.app/Contents/MacOS/main.sh +6 -0
  310. data/test/performance/tools/mac/CmdTlmServer.app/Contents/Resources/appIcon.icns +0 -0
  311. data/test/performance/tools/mac/DataViewer.app/Contents/Info.plist +38 -0
  312. data/test/performance/tools/mac/DataViewer.app/Contents/MacOS/DataViewer.rb +15 -0
  313. data/test/performance/tools/mac/DataViewer.app/Contents/MacOS/main.sh +6 -0
  314. data/test/performance/tools/mac/DataViewer.app/Contents/Resources/appIcon.icns +0 -0
  315. data/test/performance/tools/mac/HandbookCreator.app/Contents/Info.plist +38 -0
  316. data/test/performance/tools/mac/HandbookCreator.app/Contents/MacOS/HandbookCreator.rb +15 -0
  317. data/test/performance/tools/mac/HandbookCreator.app/Contents/MacOS/main.sh +6 -0
  318. data/test/performance/tools/mac/HandbookCreator.app/Contents/Resources/appIcon.icns +0 -0
  319. data/test/performance/tools/mac/Launcher.app/Contents/Info.plist +38 -0
  320. data/test/performance/tools/mac/Launcher.app/Contents/MacOS/Launcher.rb +15 -0
  321. data/test/performance/tools/mac/Launcher.app/Contents/MacOS/main.sh +6 -0
  322. data/test/performance/tools/mac/Launcher.app/Contents/Resources/appIcon.icns +0 -0
  323. data/test/performance/tools/mac/LimitsMonitor.app/Contents/Info.plist +38 -0
  324. data/test/performance/tools/mac/LimitsMonitor.app/Contents/MacOS/LimitsMonitor.rb +15 -0
  325. data/test/performance/tools/mac/LimitsMonitor.app/Contents/MacOS/main.sh +6 -0
  326. data/test/performance/tools/mac/LimitsMonitor.app/Contents/Resources/appIcon.icns +0 -0
  327. data/test/performance/tools/mac/OpenGLBuilder.app/Contents/Info.plist +38 -0
  328. data/test/performance/tools/mac/OpenGLBuilder.app/Contents/MacOS/OpenGLBuilder.rb +15 -0
  329. data/test/performance/tools/mac/OpenGLBuilder.app/Contents/MacOS/main.sh +6 -0
  330. data/test/performance/tools/mac/OpenGLBuilder.app/Contents/Resources/appIcon.icns +0 -0
  331. data/test/performance/tools/mac/PacketViewer.app/Contents/Info.plist +38 -0
  332. data/test/performance/tools/mac/PacketViewer.app/Contents/MacOS/PacketViewer.rb +15 -0
  333. data/test/performance/tools/mac/PacketViewer.app/Contents/MacOS/main.sh +6 -0
  334. data/test/performance/tools/mac/PacketViewer.app/Contents/Resources/appIcon.icns +0 -0
  335. data/test/performance/tools/mac/Replay.app/Contents/Info.plist +38 -0
  336. data/test/performance/tools/mac/Replay.app/Contents/MacOS/Replay.rb +15 -0
  337. data/test/performance/tools/mac/Replay.app/Contents/MacOS/main.sh +6 -0
  338. data/test/performance/tools/mac/Replay.app/Contents/Resources/appIcon.icns +0 -0
  339. data/test/performance/tools/mac/ScriptRunner.app/Contents/Info.plist +38 -0
  340. data/test/performance/tools/mac/ScriptRunner.app/Contents/MacOS/ScriptRunner.rb +15 -0
  341. data/test/performance/tools/mac/ScriptRunner.app/Contents/MacOS/main.sh +6 -0
  342. data/test/performance/tools/mac/ScriptRunner.app/Contents/Resources/appIcon.icns +0 -0
  343. data/test/performance/tools/mac/TableManager.app/Contents/Info.plist +38 -0
  344. data/test/performance/tools/mac/TableManager.app/Contents/MacOS/TableManager.rb +15 -0
  345. data/test/performance/tools/mac/TableManager.app/Contents/MacOS/main.sh +6 -0
  346. data/test/performance/tools/mac/TableManager.app/Contents/Resources/appIcon.icns +0 -0
  347. data/test/performance/tools/mac/TestRunner.app/Contents/Info.plist +38 -0
  348. data/test/performance/tools/mac/TestRunner.app/Contents/MacOS/TestRunner.rb +15 -0
  349. data/test/performance/tools/mac/TestRunner.app/Contents/MacOS/main.sh +6 -0
  350. data/test/performance/tools/mac/TestRunner.app/Contents/Resources/appIcon.icns +0 -0
  351. data/test/performance/tools/mac/TlmExtractor.app/Contents/Info.plist +38 -0
  352. data/test/performance/tools/mac/TlmExtractor.app/Contents/MacOS/TlmExtractor.rb +15 -0
  353. data/test/performance/tools/mac/TlmExtractor.app/Contents/MacOS/main.sh +6 -0
  354. data/test/performance/tools/mac/TlmExtractor.app/Contents/Resources/appIcon.icns +0 -0
  355. data/test/performance/tools/mac/TlmGrapher.app/Contents/Info.plist +38 -0
  356. data/test/performance/tools/mac/TlmGrapher.app/Contents/MacOS/TlmGrapher.rb +15 -0
  357. data/test/performance/tools/mac/TlmGrapher.app/Contents/MacOS/main.sh +6 -0
  358. data/test/performance/tools/mac/TlmGrapher.app/Contents/Resources/appIcon.icns +0 -0
  359. data/test/performance/tools/mac/TlmViewer.app/Contents/Info.plist +38 -0
  360. data/test/performance/tools/mac/TlmViewer.app/Contents/MacOS/TlmViewer.rb +15 -0
  361. data/test/performance/tools/mac/TlmViewer.app/Contents/MacOS/main.sh +6 -0
  362. data/test/performance/tools/mac/TlmViewer.app/Contents/Resources/appIcon.icns +0 -0
  363. data/test/performance/userpath.txt +1 -0
  364. metadata +197 -2
@@ -16,12 +16,12 @@ module Cosmos
16
16
  describe PacketLogWriterPair do
17
17
 
18
18
  describe "initialize" do
19
- it "should set the cmd writer and tlm writer" do
19
+ it "sets the cmd writer and tlm writer" do
20
20
  cmd = double("cmd_writer")
21
21
  tlm = double("tlm_writer")
22
22
  pair = PacketLogWriterPair.new(cmd, tlm)
23
- pair.cmd_log_writer.should eql cmd
24
- pair.tlm_log_writer.should eql tlm
23
+ expect(pair.cmd_log_writer).to eql cmd
24
+ expect(pair.tlm_log_writer).to eql tlm
25
25
  end
26
26
  end
27
27
 
@@ -25,11 +25,11 @@ module Cosmos
25
25
  end
26
26
 
27
27
  describe "initialize" do
28
- it "should complain with an unknown log type" do
28
+ it "complains with an unknown log type" do
29
29
  expect { PacketLogWriter.new(:BOTH) }.to raise_error
30
30
  end
31
31
 
32
- it "should create a command log writer" do
32
+ it "creates a command log writer" do
33
33
  plw = PacketLogWriter.new(:CMD,nil,true,nil,10000000,nil,false)
34
34
  plw.write(Packet.new('',''))
35
35
  plw.shutdown
@@ -37,7 +37,7 @@ module Cosmos
37
37
  sleep(0.1)
38
38
  end
39
39
 
40
- it "should create a telemetry log writer" do
40
+ it "creates a telemetry log writer" do
41
41
  plw = PacketLogWriter.new(:TLM,nil,true,nil,10000000,nil,false)
42
42
  plw.write(Packet.new('',''))
43
43
  plw.shutdown
@@ -45,7 +45,7 @@ module Cosmos
45
45
  sleep(0.1)
46
46
  end
47
47
 
48
- it "should use log_name in the filename" do
48
+ it "uses log_name in the filename" do
49
49
  plw = PacketLogWriter.new(:TLM,'test',true,nil,10000000,nil,false)
50
50
 
51
51
  plw.write(Packet.new('',''))
@@ -54,7 +54,7 @@ module Cosmos
54
54
  sleep(0.1)
55
55
  end
56
56
 
57
- it "should use the log directory" do
57
+ it "uses the log directory" do
58
58
  plw = PacketLogWriter.new(:TLM,'packet_log_writer_spec_',true,nil,10000000,Cosmos::USERPATH,false)
59
59
  plw.write(Packet.new('',''))
60
60
  plw.shutdown
@@ -67,7 +67,7 @@ module Cosmos
67
67
  end
68
68
 
69
69
  describe "write" do
70
- it "should write synchronously to a log" do
70
+ it "writes synchronously to a log" do
71
71
  plw = PacketLogWriter.new(:CMD,nil,true,nil,10000000,nil,false)
72
72
  pkt = Packet.new('tgt','pkt')
73
73
  pkt.buffer = "\x01\x02\x03\x04"
@@ -77,21 +77,21 @@ module Cosmos
77
77
  File.open(Dir[File.join(@log_path,"*.bin")][-1],'rb') do |file|
78
78
  data = file.read
79
79
  end
80
- data[-4..-1].should eql "\x01\x02\x03\x04"
80
+ expect(data[-4..-1]).to eql "\x01\x02\x03\x04"
81
81
  sleep(0.1)
82
82
  end
83
83
 
84
- it "should not write packets if logging is disabled" do
84
+ it "does not write packets if logging is disabled" do
85
85
  plw = PacketLogWriter.new(:TLM,nil,false,nil,10000000,nil,false)
86
86
  pkt = Packet.new('tgt','pkt')
87
87
  pkt.buffer = "\x01\x02\x03\x04"
88
88
  plw.write(pkt)
89
89
  plw.shutdown
90
- Dir[File.join(@log_path,"*.bin")].should be_empty
90
+ expect(Dir[File.join(@log_path,"*.bin")]).to be_empty
91
91
  sleep(0.1)
92
92
  end
93
93
 
94
- it "should cycle the log when it a size" do
94
+ it "cycles the log when it a size" do
95
95
  plw = PacketLogWriter.new(:TLM,nil,true,nil,200,nil,false)
96
96
  pkt = Packet.new('tgt','pkt')
97
97
  pkt.buffer = "\x01\x02\x03\x04"
@@ -100,15 +100,15 @@ module Cosmos
100
100
  plw.write(pkt) # size 176
101
101
  sleep 0.5
102
102
  plw.write(pkt) # size 200
103
- Dir[File.join(@log_path,"*.bin")].length.should eql 1
103
+ expect(Dir[File.join(@log_path,"*.bin")].length).to eql 1
104
104
  # This write pushs us past 200 so we should start a new file
105
105
  plw.write(pkt)
106
- Dir[File.join(@log_path,"*.bin")].length.should eql 2
106
+ expect(Dir[File.join(@log_path,"*.bin")].length).to eql 2
107
107
  plw.shutdown
108
108
  sleep(0.1)
109
109
  end
110
110
 
111
- it "should cycle the log after a set time" do
111
+ it "cycles the log after a set time" do
112
112
  # Monkey patch the constant so the test doesn't take forever
113
113
  PacketLogWriter.__send__(:remove_const,:CYCLE_TIME_INTERVAL)
114
114
  PacketLogWriter.const_set(:CYCLE_TIME_INTERVAL, 0.5)
@@ -116,7 +116,7 @@ module Cosmos
116
116
  pkt = Packet.new('tgt','pkt')
117
117
  pkt.buffer = "\x01\x02\x03\x04"
118
118
  plw.write(pkt)
119
- Dir[File.join(@log_path,"*.bin")].length.should eql 1
119
+ expect(Dir[File.join(@log_path,"*.bin")].length).to eql 1
120
120
  sleep 1
121
121
  plw.write(pkt)
122
122
  sleep 1
@@ -127,14 +127,14 @@ module Cosmos
127
127
  plw.write(pkt)
128
128
  sleep 1
129
129
  # Ensure we have two log files
130
- Dir[File.join(@log_path,"*.bin")].length.should eql 2
130
+ expect(Dir[File.join(@log_path,"*.bin")].length).to eql 2
131
131
  # Check that the log files have timestamps which are 3 (or 4) seconds apart
132
132
  files = Dir[File.join(@log_path,"*tlm.bin")].sort
133
133
  split1 = files[0].split('_')
134
134
  split2 = files[1].split('_')
135
135
  log1_time = Time.new(split1[-7].to_i, split1[-6].to_i, split1[-5].to_i, split1[-4].to_i, split1[-3].to_i, split1[-2].to_i)
136
136
  log2_time = Time.new(split2[-7].to_i, split2[-6].to_i, split2[-5].to_i, split2[-4].to_i, split2[-3].to_i, split2[-2].to_i)
137
- (log2_time - log1_time).should be_within(2).of(3)
137
+ expect(log2_time - log1_time).to be_within(2).of(3)
138
138
  plw.shutdown
139
139
  # Monkey patch the constant back to the default
140
140
  PacketLogWriter.__send__(:remove_const,:CYCLE_TIME_INTERVAL)
@@ -142,7 +142,7 @@ module Cosmos
142
142
  sleep(0.1)
143
143
  end
144
144
 
145
- it "should write asynchronously to a log" do
145
+ it "writes asynchronously to a log" do
146
146
  plw = PacketLogWriter.new(:CMD)
147
147
  pkt = Packet.new('tgt','pkt')
148
148
  pkt.buffer = "\x01\x02\x03\x04"
@@ -154,12 +154,12 @@ module Cosmos
154
154
  File.open(Dir[File.join(@log_path,"*.bin")][-1],'rb') do |file|
155
155
  data = file.read
156
156
  end
157
- data[-4..-1].should eql "\x01\x02\x03\x04"
157
+ expect(data[-4..-1]).to eql "\x01\x02\x03\x04"
158
158
  plw.shutdown
159
159
  sleep(0.1)
160
160
  end
161
161
 
162
- it "should handle errors creating the log file" do
162
+ it "handles errors creating the log file" do
163
163
  capture_io do |stdout|
164
164
  allow(File).to receive(:new) { raise "Error" }
165
165
  plw = PacketLogWriter.new(:CMD)
@@ -168,13 +168,13 @@ module Cosmos
168
168
  plw.write(pkt)
169
169
  sleep 0.1
170
170
  plw.stop
171
- stdout.string.should match "Error opening"
171
+ expect(stdout.string).to match "Error opening"
172
172
  plw.shutdown
173
173
  sleep(0.1)
174
174
  end
175
175
  end
176
176
 
177
- it "should handle errors closing the log file" do
177
+ it "handles errors closing the log file" do
178
178
  capture_io do |stdout|
179
179
  allow(File).to receive(:chmod ) { raise "Error" }
180
180
  plw = PacketLogWriter.new(:CMD)
@@ -183,7 +183,7 @@ module Cosmos
183
183
  plw.write(pkt)
184
184
  sleep 0.1
185
185
  plw.stop
186
- stdout.string.should match "Error closing"
186
+ expect(stdout.string).to match "Error closing"
187
187
  plw.shutdown
188
188
  sleep(0.1)
189
189
  end
@@ -191,17 +191,17 @@ module Cosmos
191
191
  end
192
192
 
193
193
  describe "start" do
194
- it "should enable logging" do
194
+ it "enables logging" do
195
195
  plw = PacketLogWriter.new(:TLM,nil,false,nil,10000000,nil,false)
196
196
  plw.start
197
197
  plw.write(Packet.new('',''))
198
198
  plw.shutdown
199
199
  file = Dir[File.join(@log_path,"*.bin")][-1]
200
- File.size(file).should_not eql 0
200
+ expect(File.size(file)).not_to eql 0
201
201
  sleep(0.1)
202
202
  end
203
203
 
204
- it "should add a label to the log file" do
204
+ it "adds a label to the log file" do
205
205
  plw = PacketLogWriter.new(:TLM,nil,false,nil,10000000,nil,false)
206
206
  plw.start('test')
207
207
  plw.write(Packet.new('',''))
@@ -210,7 +210,7 @@ module Cosmos
210
210
  sleep(0.1)
211
211
  end
212
212
 
213
- it "should ignore bad label formats" do
213
+ it "ignores bad label formats" do
214
214
  plw = PacketLogWriter.new(:TLM,nil,false,nil,10000000,nil,false)
215
215
  plw.start('my_test')
216
216
  plw.write(Packet.new('',''))
@@ -22,420 +22,420 @@ module Cosmos
22
22
  @data = "\x80\x81\x82\x83\x84\x85\x86\x87\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F"
23
23
  end
24
24
 
25
- it "should complain about unrecognized data types" do
26
- lambda { BinaryAccessor.read(0, 32, :BLOB, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "data_type BLOB is not recognized")
25
+ it "complains about unrecognized data types" do
26
+ expect { BinaryAccessor.read(0, 32, :BLOB, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "data_type BLOB is not recognized")
27
27
  end
28
28
 
29
- it "should complain about bit_offsets before the beginning of the buffer" do
30
- lambda { BinaryAccessor.read(-((@data.length * 8) + 8), 32, :STRING, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "#{@data.length} byte buffer insufficient to read STRING at bit_offset #{-((@data.length * 8) + 8)} with bit_size 32")
29
+ it "complains about bit_offsets before the beginning of the buffer" do
30
+ expect { BinaryAccessor.read(-((@data.length * 8) + 8), 32, :STRING, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "#{@data.length} byte buffer insufficient to read STRING at bit_offset #{-((@data.length * 8) + 8)} with bit_size 32")
31
31
  end
32
32
 
33
- it "should complain about a negative bit_offset and zero bit_size" do
34
- lambda { BinaryAccessor.read(-8, 0, :STRING, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "negative or zero bit_sizes (0) cannot be given with negative bit_offsets (-8)")
33
+ it "complains about a negative bit_offset and zero bit_size" do
34
+ expect { BinaryAccessor.read(-8, 0, :STRING, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "negative or zero bit_sizes (0) cannot be given with negative bit_offsets (-8)")
35
35
  end
36
36
 
37
- it "should complain about a negative bit_offset and negative bit_size" do
38
- lambda { BinaryAccessor.read(-8, -8, :STRING, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "negative or zero bit_sizes (-8) cannot be given with negative bit_offsets (-8)")
37
+ it "complains about a negative bit_offset and negative bit_size" do
38
+ expect { BinaryAccessor.read(-8, -8, :STRING, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "negative or zero bit_sizes (-8) cannot be given with negative bit_offsets (-8)")
39
39
  end
40
40
 
41
- it "should complain about negative bit_sizes larger than the size of the buffer" do
42
- lambda { BinaryAccessor.read(0, -((@data.length * 8) + 8), :STRING, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "#{@data.length} byte buffer insufficient to read STRING at bit_offset 0 with bit_size #{-((@data.length * 8) + 8)}")
41
+ it "complains about negative bit_sizes larger than the size of the buffer" do
42
+ expect { BinaryAccessor.read(0, -((@data.length * 8) + 8), :STRING, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "#{@data.length} byte buffer insufficient to read STRING at bit_offset 0 with bit_size #{-((@data.length * 8) + 8)}")
43
43
  end
44
44
 
45
- it "should complain about negative or zero bit_sizes with data_types other than STRING and BLOCK" do
46
- lambda { BinaryAccessor.read(0, -8, :INT, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
47
- lambda { BinaryAccessor.read(0, -8, :UINT, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
48
- lambda { BinaryAccessor.read(0, -8, :FLOAT, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
45
+ it "complains about negative or zero bit_sizes with data_types other than STRING and BLOCK" do
46
+ expect { BinaryAccessor.read(0, -8, :INT, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
47
+ expect { BinaryAccessor.read(0, -8, :UINT, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
48
+ expect { BinaryAccessor.read(0, -8, :FLOAT, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
49
49
  end
50
50
 
51
- it "should read aligned strings" do
51
+ it "reads aligned strings" do
52
52
  0.step((@data.length - 1) * 8, 8) do |bit_offset|
53
53
  if (bit_offset / 8) <= 7
54
- BinaryAccessor.read(bit_offset, (@data.length * 8) - bit_offset, :STRING, @data, :BIG_ENDIAN).should eql(@data[(bit_offset / 8)..7])
54
+ expect(BinaryAccessor.read(bit_offset, (@data.length * 8) - bit_offset, :STRING, @data, :BIG_ENDIAN)).to eql(@data[(bit_offset / 8)..7])
55
55
  elsif (bit_offset / 8) == 8
56
- BinaryAccessor.read(bit_offset, (@data.length * 8) - bit_offset, :STRING, @data, :BIG_ENDIAN).should eql('')
56
+ expect(BinaryAccessor.read(bit_offset, (@data.length * 8) - bit_offset, :STRING, @data, :BIG_ENDIAN)).to eql('')
57
57
  else
58
- BinaryAccessor.read(bit_offset, (@data.length * 8) - bit_offset, :STRING, @data, :BIG_ENDIAN).should eql(@data[(bit_offset / 8)..-1])
58
+ expect(BinaryAccessor.read(bit_offset, (@data.length * 8) - bit_offset, :STRING, @data, :BIG_ENDIAN)).to eql(@data[(bit_offset / 8)..-1])
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
- it "should read variable length strings with a zero and negative bit_size" do
63
+ it "reads variable length strings with a zero and negative bit_size" do
64
64
  0.step(-(@data.length * 8), -8) do |bit_size|
65
65
  if (bit_size / 8) >= -8
66
- BinaryAccessor.read(0, bit_size, :STRING, @data, :BIG_ENDIAN).should eql(@data[0..7])
66
+ expect(BinaryAccessor.read(0, bit_size, :STRING, @data, :BIG_ENDIAN)).to eql(@data[0..7])
67
67
  else
68
- BinaryAccessor.read(0, bit_size, :STRING, @data, :BIG_ENDIAN).should eql(@data[0..((bit_size / 8) - 1)])
68
+ expect(BinaryAccessor.read(0, bit_size, :STRING, @data, :BIG_ENDIAN)).to eql(@data[0..((bit_size / 8) - 1)])
69
69
  end
70
70
  end
71
71
  end
72
72
 
73
- it "should read strings with negative bit_offsets" do
74
- BinaryAccessor.read(-16, 16, :STRING, @data, :BIG_ENDIAN).should eql(@data[-2..-1])
73
+ it "reads strings with negative bit_offsets" do
74
+ expect(BinaryAccessor.read(-16, 16, :STRING, @data, :BIG_ENDIAN)).to eql(@data[-2..-1])
75
75
  end
76
76
 
77
- it "should complain about unaligned strings" do
78
- lambda { BinaryAccessor.read(1, 32, :STRING, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type STRING")
77
+ it "complains about unaligned strings" do
78
+ expect { BinaryAccessor.read(1, 32, :STRING, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type STRING")
79
79
  end
80
80
 
81
- it "should read aligned blocks" do
81
+ it "reads aligned blocks" do
82
82
  0.step((@data.length - 1) * 8, 8) do |bit_offset|
83
- BinaryAccessor.read(bit_offset, (@data.length * 8) - bit_offset, :BLOCK, @data, :BIG_ENDIAN).should eql(@data[(bit_offset / 8)..-1])
83
+ expect(BinaryAccessor.read(bit_offset, (@data.length * 8) - bit_offset, :BLOCK, @data, :BIG_ENDIAN)).to eql(@data[(bit_offset / 8)..-1])
84
84
  end
85
85
  end
86
86
 
87
- it "should read variable length blocks with a zero and negative bit_size" do
87
+ it "reads variable length blocks with a zero and negative bit_size" do
88
88
  0.step(-(@data.length * 8), -8) do |bit_size|
89
- BinaryAccessor.read(0, bit_size, :BLOCK, @data, :BIG_ENDIAN).should eql(@data[0..((bit_size / 8) - 1)])
89
+ expect(BinaryAccessor.read(0, bit_size, :BLOCK, @data, :BIG_ENDIAN)).to eql(@data[0..((bit_size / 8) - 1)])
90
90
  end
91
91
  end
92
92
 
93
- it "should read blocks with negative bit_offsets" do
94
- BinaryAccessor.read(-16, 16, :BLOCK, @data, :BIG_ENDIAN).should eql(@data[-2..-1])
93
+ it "reads blocks with negative bit_offsets" do
94
+ expect(BinaryAccessor.read(-16, 16, :BLOCK, @data, :BIG_ENDIAN)).to eql(@data[-2..-1])
95
95
  end
96
96
 
97
- it "should complain about unaligned blocks" do
98
- lambda { BinaryAccessor.read(7, 16, :BLOCK, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "bit_offset 7 is not byte aligned for data_type BLOCK")
97
+ it "complains about unaligned blocks" do
98
+ expect { BinaryAccessor.read(7, 16, :BLOCK, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "bit_offset 7 is not byte aligned for data_type BLOCK")
99
99
  end
100
100
 
101
- it "should complain if read exceeds the size of the buffer" do
102
- lambda { BinaryAccessor.read(8, 800, :STRING, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "16 byte buffer insufficient to read STRING at bit_offset 8 with bit_size 800")
101
+ it "complains if read exceeds the size of the buffer" do
102
+ expect { BinaryAccessor.read(8, 800, :STRING, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "16 byte buffer insufficient to read STRING at bit_offset 8 with bit_size 800")
103
103
  end
104
104
 
105
- it "should read aligned 8-bit unsigned integers" do
105
+ it "reads aligned 8-bit unsigned integers" do
106
106
  0.step((@data.length - 1) * 8, 8) do |bit_offset|
107
- BinaryAccessor.read(bit_offset, 8, :UINT, @data, :BIG_ENDIAN).should eql(@data.getbyte(bit_offset / 8))
107
+ expect(BinaryAccessor.read(bit_offset, 8, :UINT, @data, :BIG_ENDIAN)).to eql(@data.getbyte(bit_offset / 8))
108
108
  end
109
109
  end
110
110
 
111
- it "should read aligned 8-bit signed integers" do
111
+ it "reads aligned 8-bit signed integers" do
112
112
  0.step((@data.length - 1) * 8, 8) do |bit_offset|
113
113
  expected = @data.getbyte(bit_offset / 8)
114
114
  expected = expected - 256 if expected >= 128
115
- BinaryAccessor.read(bit_offset, 8, :INT, @data, :BIG_ENDIAN).should eql(expected)
115
+ expect(BinaryAccessor.read(bit_offset, 8, :INT, @data, :BIG_ENDIAN)).to eql(expected)
116
116
  end
117
117
  end
118
118
 
119
119
  describe "given big endian data" do
120
120
 
121
- it "should read 1-bit unsigned integers" do
121
+ it "reads 1-bit unsigned integers" do
122
122
  expected = [0x1, 0x0]
123
123
  bit_size = 1
124
- BinaryAccessor.read(8, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[0])
125
- BinaryAccessor.read(9, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[1])
124
+ expect(BinaryAccessor.read(8, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[0])
125
+ expect(BinaryAccessor.read(9, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[1])
126
126
  end
127
127
 
128
- it "should read 1-bit signed integers" do
128
+ it "reads 1-bit signed integers" do
129
129
  expected = [0x1, 0x0]
130
130
  bit_size = 1
131
- BinaryAccessor.read(8, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[0])
132
- BinaryAccessor.read(9, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[1])
131
+ expect(BinaryAccessor.read(8, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[0])
132
+ expect(BinaryAccessor.read(9, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[1])
133
133
  end
134
134
 
135
- it "should read 7-bit unsigned integers" do
135
+ it "reads 7-bit unsigned integers" do
136
136
  expected = [0x40, 0x02]
137
137
  bit_size = 7
138
- BinaryAccessor.read(8, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[0])
139
- BinaryAccessor.read(3, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[1])
138
+ expect(BinaryAccessor.read(8, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[0])
139
+ expect(BinaryAccessor.read(3, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[1])
140
140
  end
141
141
 
142
- it "should read 7-bit signed integers" do
142
+ it "reads 7-bit signed integers" do
143
143
  expected = [0x40, 0x02]
144
144
  bit_size = 7
145
145
  expected.each_with_index { |value, index| expected[index] = value - 2**bit_size if value >= 2**(bit_size - 1) }
146
- BinaryAccessor.read(8, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[0])
147
- BinaryAccessor.read(3, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[1])
146
+ expect(BinaryAccessor.read(8, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[0])
147
+ expect(BinaryAccessor.read(3, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[1])
148
148
  end
149
149
 
150
- it "should read 13-bit unsigned integers" do
150
+ it "reads 13-bit unsigned integers" do
151
151
  expected = [0x1C24, 0x20]
152
152
  bit_size = 13
153
- BinaryAccessor.read(30, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[0])
154
- BinaryAccessor.read(1, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[1])
153
+ expect(BinaryAccessor.read(30, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[0])
154
+ expect(BinaryAccessor.read(1, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[1])
155
155
  end
156
156
 
157
- it "should read 13-bit signed integers" do
157
+ it "reads 13-bit signed integers" do
158
158
  expected = [0x1C24, 0x20]
159
159
  bit_size = 13
160
160
  expected.each_with_index { |value, index| expected[index] = value - 2**bit_size if value >= 2**(bit_size - 1) }
161
- BinaryAccessor.read(30, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[0])
162
- BinaryAccessor.read(1, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[1])
161
+ expect(BinaryAccessor.read(30, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[0])
162
+ expect(BinaryAccessor.read(1, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[1])
163
163
  end
164
164
 
165
- it "should read aligned 16-bit unsigned integers" do
165
+ it "reads aligned 16-bit unsigned integers" do
166
166
  expected_array = [0x8081, 0x8283, 0x8485, 0x8687, 0x0009, 0x0A0B, 0x0C0D, 0x0E0F]
167
167
  index = 0
168
168
  0.step((@data.length - 1) * 8, 16) do |bit_offset|
169
- BinaryAccessor.read(bit_offset, 16, :UINT, @data, :BIG_ENDIAN).should eql(expected_array[index])
169
+ expect(BinaryAccessor.read(bit_offset, 16, :UINT, @data, :BIG_ENDIAN)).to eql(expected_array[index])
170
170
  index += 1
171
171
  end
172
172
  end
173
173
 
174
- it "should read aligned 16-bit signed integers" do
174
+ it "reads aligned 16-bit signed integers" do
175
175
  expected_array = [0x8081, 0x8283, 0x8485, 0x8687, 0x0009, 0x0A0B, 0x0C0D, 0x0E0F]
176
176
  index = 0
177
177
  0.step((@data.length - 1) * 8, 16) do |bit_offset|
178
178
  expected = expected_array[index]
179
179
  expected = expected - 2**16 if expected >= 2**15
180
- BinaryAccessor.read(bit_offset, 16, :INT, @data, :BIG_ENDIAN).should eql(expected)
180
+ expect(BinaryAccessor.read(bit_offset, 16, :INT, @data, :BIG_ENDIAN)).to eql(expected)
181
181
  index += 1
182
182
  end
183
183
  end
184
184
 
185
- it "should read aligned 32-bit unsigned integers" do
185
+ it "reads aligned 32-bit unsigned integers" do
186
186
  expected_array = [0x80818283, 0x84858687, 0x00090A0B, 0x0C0D0E0F]
187
187
  index = 0
188
188
  0.step((@data.length - 1) * 8, 32) do |bit_offset|
189
- BinaryAccessor.read(bit_offset, 32, :UINT, @data, :BIG_ENDIAN).should eql(expected_array[index])
189
+ expect(BinaryAccessor.read(bit_offset, 32, :UINT, @data, :BIG_ENDIAN)).to eql(expected_array[index])
190
190
  index += 1
191
191
  end
192
192
  end
193
193
 
194
- it "should read aligned 32-bit signed integers" do
194
+ it "reads aligned 32-bit signed integers" do
195
195
  expected_array = [0x80818283, 0x84858687, 0x00090A0B, 0x0C0D0E0F]
196
196
  index = 0
197
197
  0.step((@data.length - 1) * 8, 32) do |bit_offset|
198
198
  expected = expected_array[index]
199
199
  expected = expected - 2**32 if expected >= 2**31
200
- BinaryAccessor.read(bit_offset, 32, :INT, @data, :BIG_ENDIAN).should eql(expected)
200
+ expect(BinaryAccessor.read(bit_offset, 32, :INT, @data, :BIG_ENDIAN)).to eql(expected)
201
201
  index += 1
202
202
  end
203
203
  end
204
204
 
205
- it "should read aligned 32-bit floats" do
205
+ it "reads aligned 32-bit floats" do
206
206
  expected_array = [-1.189360e-038, -3.139169e-036, 8.301067e-040, 1.086646e-031]
207
- BinaryAccessor.read(0, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-038).of(expected_array[0])
208
- BinaryAccessor.read(32, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-036).of(expected_array[1])
209
- BinaryAccessor.read(64, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-040).of(expected_array[2])
210
- BinaryAccessor.read(96, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-031).of(expected_array[3])
207
+ expect(BinaryAccessor.read(0, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-038).of(expected_array[0])
208
+ expect(BinaryAccessor.read(32, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-036).of(expected_array[1])
209
+ expect(BinaryAccessor.read(64, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-040).of(expected_array[2])
210
+ expect(BinaryAccessor.read(96, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-031).of(expected_array[3])
211
211
  end
212
212
 
213
- it "should read 37-bit unsigned integers" do
213
+ it "reads 37-bit unsigned integers" do
214
214
  expected = [0x8182838485 >> 3, 0x00090A0B0C]
215
215
  bit_size = 37
216
- BinaryAccessor.read(8, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[0])
217
- BinaryAccessor.read(67, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[1])
216
+ expect(BinaryAccessor.read(8, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[0])
217
+ expect(BinaryAccessor.read(67, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[1])
218
218
  end
219
219
 
220
- it "should read 37-bit signed integers" do
220
+ it "reads 37-bit signed integers" do
221
221
  expected = [0x8182838485 >> 3, 0x00090A0B0C]
222
222
  bit_size = 37
223
223
  expected.each_with_index { |value, index| expected[index] = value - 2**bit_size if value >= 2**(bit_size - 1) }
224
- BinaryAccessor.read(8, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[0])
225
- BinaryAccessor.read(67, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[1])
224
+ expect(BinaryAccessor.read(8, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[0])
225
+ expect(BinaryAccessor.read(67, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[1])
226
226
  end
227
227
 
228
- it "should read 63-bit unsigned integers" do
228
+ it "reads 63-bit unsigned integers" do
229
229
  expected = [0x8081828384858687 >> 1, 0x00090A0B0C0D0E0F]
230
230
  bit_size = 63
231
- BinaryAccessor.read(0, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[0])
232
- BinaryAccessor.read(65, bit_size, :UINT, @data, :BIG_ENDIAN).should eql(expected[1])
231
+ expect(BinaryAccessor.read(0, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[0])
232
+ expect(BinaryAccessor.read(65, bit_size, :UINT, @data, :BIG_ENDIAN)).to eql(expected[1])
233
233
  end
234
234
 
235
- it "should read 63-bit signed integers" do
235
+ it "reads 63-bit signed integers" do
236
236
  expected = [0x8081828384858687 >> 1, 0x00090A0B0C0D0E0F]
237
237
  bit_size = 63
238
238
  expected.each_with_index { |value, index| expected[index] = value - 2**bit_size if value >= 2**(bit_size - 1) }
239
- BinaryAccessor.read(0, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[0])
240
- BinaryAccessor.read(65, bit_size, :INT, @data, :BIG_ENDIAN).should eql(expected[1])
239
+ expect(BinaryAccessor.read(0, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[0])
240
+ expect(BinaryAccessor.read(65, bit_size, :INT, @data, :BIG_ENDIAN)).to eql(expected[1])
241
241
  end
242
242
 
243
- it "should read aligned 64-bit unsigned integers" do
243
+ it "reads aligned 64-bit unsigned integers" do
244
244
  expected_array = [0x8081828384858687, 0x00090A0B0C0D0E0F]
245
245
  index = 0
246
246
  0.step((@data.length - 1) * 8, 64) do |bit_offset|
247
- BinaryAccessor.read(bit_offset, 64, :UINT, @data, :BIG_ENDIAN).should eql(expected_array[index])
247
+ expect(BinaryAccessor.read(bit_offset, 64, :UINT, @data, :BIG_ENDIAN)).to eql(expected_array[index])
248
248
  index += 1
249
249
  end
250
250
  end
251
251
 
252
- it "should read aligned 64-bit signed integers" do
252
+ it "reads aligned 64-bit signed integers" do
253
253
  expected_array = [0x8081828384858687, 0x00090A0B0C0D0E0F]
254
254
  index = 0
255
255
  0.step((@data.length - 1) * 8, 64) do |bit_offset|
256
256
  expected = expected_array[index]
257
257
  expected = expected - 2**64 if expected >= 2**63
258
- BinaryAccessor.read(bit_offset, 64, :INT, @data, :BIG_ENDIAN).should eql(expected)
258
+ expect(BinaryAccessor.read(bit_offset, 64, :INT, @data, :BIG_ENDIAN)).to eql(expected)
259
259
  index += 1
260
260
  end
261
261
  end
262
262
 
263
- it "should read aligned 64-bit floats" do
263
+ it "reads aligned 64-bit floats" do
264
264
  expected_array = [-3.116851e-306, 1.257060e-308]
265
- BinaryAccessor.read(0, 64, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-306).of(expected_array[0])
266
- BinaryAccessor.read(64, 64, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-308).of(expected_array[1])
265
+ expect(BinaryAccessor.read(0, 64, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-306).of(expected_array[0])
266
+ expect(BinaryAccessor.read(64, 64, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-308).of(expected_array[1])
267
267
  end
268
268
 
269
- it "should complain about unaligned floats" do
270
- lambda { BinaryAccessor.read(17, 32, :FLOAT, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "bit_offset 17 is not byte aligned for data_type FLOAT")
269
+ it "complains about unaligned floats" do
270
+ expect { BinaryAccessor.read(17, 32, :FLOAT, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "bit_offset 17 is not byte aligned for data_type FLOAT")
271
271
  end
272
272
 
273
- it "should complain about mis-sized floats" do
274
- lambda { BinaryAccessor.read(0, 33, :FLOAT, @data, :BIG_ENDIAN) }.should raise_error(ArgumentError, "bit_size is 33 but must be 32 or 64 for data_type FLOAT")
273
+ it "complains about mis-sized floats" do
274
+ expect { BinaryAccessor.read(0, 33, :FLOAT, @data, :BIG_ENDIAN) }.to raise_error(ArgumentError, "bit_size is 33 but must be 32 or 64 for data_type FLOAT")
275
275
  end
276
276
 
277
277
  end # given big endian data
278
278
 
279
279
  describe "given little endian data" do
280
280
 
281
- it "should complain about ill-defined little endian bitfields" do
282
- lambda { BinaryAccessor.read(3, 7, :UINT, @data, :LITTLE_ENDIAN) }.should raise_error(ArgumentError, "LITTLE_ENDIAN bitfield with bit_offset 3 and bit_size 7 is invalid")
281
+ it "complains about ill-defined little endian bitfields" do
282
+ expect { BinaryAccessor.read(3, 7, :UINT, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "LITTLE_ENDIAN bitfield with bit_offset 3 and bit_size 7 is invalid")
283
283
  end
284
284
 
285
- it "should read 1-bit unsigned integers" do
285
+ it "reads 1-bit unsigned integers" do
286
286
  expected = [0x1, 0x0]
287
287
  bit_size = 1
288
- BinaryAccessor.read(8, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[0])
289
- BinaryAccessor.read(9, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[1])
288
+ expect(BinaryAccessor.read(8, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
289
+ expect(BinaryAccessor.read(9, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
290
290
  end
291
291
 
292
- it "should read 1-bit signed integers" do
292
+ it "reads 1-bit signed integers" do
293
293
  expected = [0x1, 0x0]
294
294
  bit_size = 1
295
- BinaryAccessor.read(8, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[0])
296
- BinaryAccessor.read(9, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[1])
295
+ expect(BinaryAccessor.read(8, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
296
+ expect(BinaryAccessor.read(9, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
297
297
  end
298
298
 
299
- it "should read 7-bit unsigned integers" do
299
+ it "reads 7-bit unsigned integers" do
300
300
  expected = [0x40, 0x60]
301
301
  bit_size = 7
302
- BinaryAccessor.read(8, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[0])
303
- BinaryAccessor.read(15, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[1])
302
+ expect(BinaryAccessor.read(8, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
303
+ expect(BinaryAccessor.read(15, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
304
304
  end
305
305
 
306
- it "should read 7-bit signed integers" do
306
+ it "reads 7-bit signed integers" do
307
307
  expected = [0x40, 0x60]
308
308
  bit_size = 7
309
309
  expected.each_with_index { |value, index| expected[index] = value - 2**bit_size if value >= 2**(bit_size - 1) }
310
- BinaryAccessor.read(8, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[0])
311
- BinaryAccessor.read(15, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[1])
310
+ expect(BinaryAccessor.read(8, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
311
+ expect(BinaryAccessor.read(15, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
312
312
  end
313
313
 
314
- it "should read 13-bit unsigned integers" do
314
+ it "reads 13-bit unsigned integers" do
315
315
  expected = [0x038281 >> 5, 0x0180 >> 2]
316
316
  bit_size = 13
317
- BinaryAccessor.read(30, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[0])
318
- BinaryAccessor.read(9, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[1])
317
+ expect(BinaryAccessor.read(30, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
318
+ expect(BinaryAccessor.read(9, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
319
319
  end
320
320
 
321
- it "should read 13-bit signed integers" do
321
+ it "reads 13-bit signed integers" do
322
322
  expected = [0x038281 >> 5, 0x0180 >> 2]
323
323
  bit_size = 13
324
324
  expected.each_with_index { |value, index| expected[index] = value - 2**bit_size if value >= 2**(bit_size - 1) }
325
- BinaryAccessor.read(30, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[0])
326
- BinaryAccessor.read(9, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[1])
325
+ expect(BinaryAccessor.read(30, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
326
+ expect(BinaryAccessor.read(9, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
327
327
  end
328
328
 
329
- it "should read aligned 16-bit unsigned integers" do
329
+ it "reads aligned 16-bit unsigned integers" do
330
330
  expected_array = [0x8180, 0x8382, 0x8584, 0x8786, 0x0900, 0x0B0A, 0x0D0C, 0x0F0E]
331
331
  index = 0
332
332
  0.step((@data.length - 1) * 8, 16) do |bit_offset|
333
- BinaryAccessor.read(bit_offset, 16, :UINT, @data, :LITTLE_ENDIAN).should eql(expected_array[index])
333
+ expect(BinaryAccessor.read(bit_offset, 16, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected_array[index])
334
334
  index += 1
335
335
  end
336
336
  end
337
337
 
338
- it "should read aligned 16-bit signed integers" do
338
+ it "reads aligned 16-bit signed integers" do
339
339
  expected_array = [0x8180, 0x8382, 0x8584, 0x8786, 0x0900, 0x0B0A, 0x0D0C, 0x0F0E]
340
340
  index = 0
341
341
  0.step((@data.length - 1) * 8, 16) do |bit_offset|
342
342
  expected = expected_array[index]
343
343
  expected = expected - 2**16 if expected >= 2**15
344
- BinaryAccessor.read(bit_offset, 16, :INT, @data, :LITTLE_ENDIAN).should eql(expected)
344
+ expect(BinaryAccessor.read(bit_offset, 16, :INT, @data, :LITTLE_ENDIAN)).to eql(expected)
345
345
  index += 1
346
346
  end
347
347
  end
348
348
 
349
- it "should read aligned 32-bit unsigned integers" do
349
+ it "reads aligned 32-bit unsigned integers" do
350
350
  expected_array = [0x83828180, 0x87868584, 0x0B0A0900, 0x0F0E0D0C]
351
351
  index = 0
352
352
  0.step((@data.length - 1) * 8, 32) do |bit_offset|
353
- BinaryAccessor.read(bit_offset, 32, :UINT, @data, :LITTLE_ENDIAN).should eql(expected_array[index])
353
+ expect(BinaryAccessor.read(bit_offset, 32, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected_array[index])
354
354
  index += 1
355
355
  end
356
356
  end
357
357
 
358
- it "should read aligned 32-bit signed integers" do
358
+ it "reads aligned 32-bit signed integers" do
359
359
  expected_array = [0x83828180, 0x87868584, 0x0B0A0900, 0x0F0E0D0C]
360
360
  index = 0
361
361
  0.step((@data.length - 1) * 8, 32) do |bit_offset|
362
362
  expected = expected_array[index]
363
363
  expected = expected - 2**32 if expected >= 2**31
364
- BinaryAccessor.read(bit_offset, 32, :INT, @data, :LITTLE_ENDIAN).should eql(expected)
364
+ expect(BinaryAccessor.read(bit_offset, 32, :INT, @data, :LITTLE_ENDIAN)).to eql(expected)
365
365
  index += 1
366
366
  end
367
367
  end
368
368
 
369
- it "should read aligned 32-bit floats" do
369
+ it "reads aligned 32-bit floats" do
370
370
  expected_array = [-7.670445e-037, -2.024055e-034, 2.658460e-032, 7.003653e-030]
371
- BinaryAccessor.read(0, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-037).of(expected_array[0])
372
- BinaryAccessor.read(32, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-034).of(expected_array[1])
373
- BinaryAccessor.read(64, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-032).of(expected_array[2])
374
- BinaryAccessor.read(96, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-030).of(expected_array[3])
371
+ expect(BinaryAccessor.read(0, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-037).of(expected_array[0])
372
+ expect(BinaryAccessor.read(32, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-034).of(expected_array[1])
373
+ expect(BinaryAccessor.read(64, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-032).of(expected_array[2])
374
+ expect(BinaryAccessor.read(96, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-030).of(expected_array[3])
375
375
  end
376
376
 
377
- it "should read 37-bit unsigned integers" do
377
+ it "reads 37-bit unsigned integers" do
378
378
  expected = [0x8584838281 >> 3, 0x0F0E0D0C0B]
379
379
  bit_size = 37
380
- BinaryAccessor.read(40, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[0])
381
- BinaryAccessor.read(123, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[1])
380
+ expect(BinaryAccessor.read(40, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
381
+ expect(BinaryAccessor.read(123, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
382
382
  end
383
383
 
384
- it "should read 37-bit signed integers" do
384
+ it "reads 37-bit signed integers" do
385
385
  expected = [0x8584838281 >> 3, 0x0F0E0D0C0B]
386
386
  bit_size = 37
387
387
  expected.each_with_index { |value, index| expected[index] = value - 2**bit_size if value >= 2**(bit_size - 1) }
388
- BinaryAccessor.read(40, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[0])
389
- BinaryAccessor.read(123, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[1])
388
+ expect(BinaryAccessor.read(40, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
389
+ expect(BinaryAccessor.read(123, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
390
390
  end
391
391
 
392
- it "should read 63-bit unsigned integers" do
392
+ it "reads 63-bit unsigned integers" do
393
393
  expected = [0x0F0E0D0C0B0A0900 >> 1, 0x0786858483828180]
394
394
  bit_size = 63
395
- BinaryAccessor.read(120, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[0])
396
- BinaryAccessor.read(57, bit_size, :UINT, @data, :LITTLE_ENDIAN).should eql(expected[1])
395
+ expect(BinaryAccessor.read(120, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
396
+ expect(BinaryAccessor.read(57, bit_size, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
397
397
  end
398
398
 
399
- it "should read 63-bit signed integers" do
399
+ it "reads 63-bit signed integers" do
400
400
  expected = [0x0F0E0D0C0B0A0900 >> 1, 0x0786858483828180]
401
401
  bit_size = 63
402
402
  expected.each_with_index { |value, index| expected[index] = value - 2**bit_size if value >= 2**(bit_size - 1) }
403
- BinaryAccessor.read(120, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[0])
404
- BinaryAccessor.read(57, bit_size, :INT, @data, :LITTLE_ENDIAN).should eql(expected[1])
403
+ expect(BinaryAccessor.read(120, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[0])
404
+ expect(BinaryAccessor.read(57, bit_size, :INT, @data, :LITTLE_ENDIAN)).to eql(expected[1])
405
405
  end
406
406
 
407
- it "should read aligned 64-bit unsigned integers" do
407
+ it "reads aligned 64-bit unsigned integers" do
408
408
  expected_array = [0x8786858483828180, 0x0F0E0D0C0B0A0900]
409
409
  index = 0
410
410
  0.step((@data.length - 1) * 8, 64) do |bit_offset|
411
- BinaryAccessor.read(bit_offset, 64, :UINT, @data, :LITTLE_ENDIAN).should eql(expected_array[index])
411
+ expect(BinaryAccessor.read(bit_offset, 64, :UINT, @data, :LITTLE_ENDIAN)).to eql(expected_array[index])
412
412
  index += 1
413
413
  end
414
414
  end
415
415
 
416
- it "should read aligned 64-bit signed integers" do
416
+ it "reads aligned 64-bit signed integers" do
417
417
  expected_array = [0x8786858483828180, 0x0F0E0D0C0B0A0900]
418
418
  index = 0
419
419
  0.step((@data.length - 1) * 8, 64) do |bit_offset|
420
420
  expected = expected_array[index]
421
421
  expected = expected - 2**64 if expected >= 2**63
422
- BinaryAccessor.read(bit_offset, 64, :INT, @data, :LITTLE_ENDIAN).should eql(expected)
422
+ expect(BinaryAccessor.read(bit_offset, 64, :INT, @data, :LITTLE_ENDIAN)).to eql(expected)
423
423
  index += 1
424
424
  end
425
425
  end
426
426
 
427
- it "should read aligned 64-bit floats" do
427
+ it "reads aligned 64-bit floats" do
428
428
  expected_array = [-2.081577e-272, 3.691916e-236]
429
- BinaryAccessor.read(0, 64, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-272).of(expected_array[0])
430
- BinaryAccessor.read(64, 64, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-236).of(expected_array[1])
429
+ expect(BinaryAccessor.read(0, 64, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-272).of(expected_array[0])
430
+ expect(BinaryAccessor.read(64, 64, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-236).of(expected_array[1])
431
431
  end
432
432
 
433
- it "should complain about unaligned floats" do
434
- lambda { BinaryAccessor.read(1, 32, :FLOAT, @data, :LITTLE_ENDIAN) }.should raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type FLOAT")
433
+ it "complains about unaligned floats" do
434
+ expect { BinaryAccessor.read(1, 32, :FLOAT, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type FLOAT")
435
435
  end
436
436
 
437
- it "should complain about mis-sized floats" do
438
- lambda { BinaryAccessor.read(0, 65, :FLOAT, @data, :LITTLE_ENDIAN) }.should raise_error(ArgumentError, "bit_size is 65 but must be 32 or 64 for data_type FLOAT")
437
+ it "complains about mis-sized floats" do
438
+ expect { BinaryAccessor.read(0, 65, :FLOAT, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "bit_size is 65 but must be 32 or 64 for data_type FLOAT")
439
439
  end
440
440
 
441
441
  end # little endian
@@ -447,54 +447,54 @@ module Cosmos
447
447
  @data = "\x80\x81\x82\x83\x84\x85\x86\x87\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F"
448
448
  end
449
449
 
450
- it "should complain with unknown data_type" do
450
+ it "complains with unknown data_type" do
451
451
  expect { BinaryAccessor.read_array(0, 8, :BLAH, 0, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "data_type BLAH is not recognized")
452
452
  end
453
453
 
454
454
  describe "given little endian data" do
455
455
 
456
- it "should complain about negative bit sizes" do
456
+ it "complains about negative bit sizes" do
457
457
  expect { BinaryAccessor.read_array(0, -8, :UINT, @data.length*8, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "bit_size -8 must be positive for arrays")
458
458
  end
459
459
 
460
460
  context "when positive or zero bit_offset" do
461
- it "should read the given array_size amount of items" do
461
+ it "reads the given array_size amount of items" do
462
462
  data = @data.unpack('C*')
463
- BinaryAccessor.read_array(0, 8, :UINT, 32, @data, :LITTLE_ENDIAN).should eql(data[0..3])
463
+ expect(BinaryAccessor.read_array(0, 8, :UINT, 32, @data, :LITTLE_ENDIAN)).to eql(data[0..3])
464
464
  end
465
465
 
466
- it "should read the given array_size amount of items" do
466
+ it "reads the given array_size amount of items" do
467
467
  data = @data.unpack('C*')
468
- BinaryAccessor.read_array(32, 8, :UINT, 32, @data, :LITTLE_ENDIAN).should eql(data[4..7])
468
+ expect(BinaryAccessor.read_array(32, 8, :UINT, 32, @data, :LITTLE_ENDIAN)).to eql(data[4..7])
469
469
  end
470
470
 
471
- it "should read the total buffer given array_size = buffer size" do
471
+ it "reads the total buffer given array_size = buffer size" do
472
472
  data = @data.unpack('c*')
473
473
 
474
- BinaryAccessor.read_array(0, 8, :INT, @data.length*8, @data, :LITTLE_ENDIAN).should eql(data)
474
+ expect(BinaryAccessor.read_array(0, 8, :INT, @data.length*8, @data, :LITTLE_ENDIAN)).to eql(data)
475
475
  end
476
476
 
477
- it "should complain with an array_size not a multiple of bit_size" do
477
+ it "complains with an array_size not a multiple of bit_size" do
478
478
  data = @data.unpack('C*')
479
479
  expect { BinaryAccessor.read_array(0, 8, :UINT, 10, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "array_size 10 not a multiple of bit_size 8")
480
480
  end
481
481
 
482
- it "should read as many items as possible with a zero array_size" do
482
+ it "reads as many items as possible with a zero array_size" do
483
483
  data = @data.unpack('C*')
484
- BinaryAccessor.read_array(0, 8, :UINT, 0, @data, :LITTLE_ENDIAN).should eql(data)
484
+ expect(BinaryAccessor.read_array(0, 8, :UINT, 0, @data, :LITTLE_ENDIAN)).to eql(data)
485
485
  end
486
486
 
487
- it "should exclude the remaining bits if array_size is negative" do
487
+ it "excludes the remaining bits if array_size is negative" do
488
488
  data = @data.unpack('C*')
489
- BinaryAccessor.read_array(0, 8, :UINT, -32, @data, :LITTLE_ENDIAN).should eql(data[0..-5])
489
+ expect(BinaryAccessor.read_array(0, 8, :UINT, -32, @data, :LITTLE_ENDIAN)).to eql(data[0..-5])
490
490
  end
491
491
 
492
- it "should return an empty array if the offset equals the negative array size" do
492
+ it "returns an empty array if the offset equals the negative array size" do
493
493
  data = @data.unpack('C*')
494
- BinaryAccessor.read_array(@data.length*8-32, 8, :UINT, -32, @data, :LITTLE_ENDIAN).should eql([])
494
+ expect(BinaryAccessor.read_array(@data.length*8-32, 8, :UINT, -32, @data, :LITTLE_ENDIAN)).to eql([])
495
495
  end
496
496
 
497
- it "should complain if the offset is greater than the negative array size" do
497
+ it "complains if the offset is greater than the negative array size" do
498
498
  data = @data.unpack('C*')
499
499
  offset = @data.length * 8 - 16
500
500
  expect { BinaryAccessor.read_array(offset, 8, :UINT, -32, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "16 byte buffer insufficient to read UINT at bit_offset #{offset} with bit_size 8")
@@ -502,176 +502,176 @@ module Cosmos
502
502
  end
503
503
 
504
504
  context "when negative bit_offset" do
505
- it "should read an array of aligned 8 bit unsigned integers" do
505
+ it "reads an array of aligned 8 bit unsigned integers" do
506
506
  data = @data.unpack('C*')
507
- BinaryAccessor.read_array(-32, 8, :UINT, 32, @data, :LITTLE_ENDIAN).should eql(data[-4..-1])
507
+ expect(BinaryAccessor.read_array(-32, 8, :UINT, 32, @data, :LITTLE_ENDIAN)).to eql(data[-4..-1])
508
508
  end
509
509
 
510
- it "should read an array if the negative offset is the size of the array" do
510
+ it "reads an array if the negative offset is the size of the array" do
511
511
  data = @data.unpack('C*')
512
- BinaryAccessor.read_array(-(@data.length*8), 8, :UINT, @data.length*8, @data, :LITTLE_ENDIAN).should eql(data)
512
+ expect(BinaryAccessor.read_array(-(@data.length*8), 8, :UINT, @data.length*8, @data, :LITTLE_ENDIAN)).to eql(data)
513
513
  end
514
514
 
515
- it "should complain if the offset is larger than the buffer" do
515
+ it "complains if the offset is larger than the buffer" do
516
516
  expect { BinaryAccessor.read_array(-(@data.length*8+1), 8, :UINT, @data.length*8, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "#{@data.length} byte buffer insufficient to read #{:UINT} at bit_offset -#{@data.length*8+1} with bit_size 8")
517
517
  end
518
518
 
519
- it "should complain with zero array_size" do
519
+ it "complains with zero array_size" do
520
520
  expect { BinaryAccessor.read_array(-32, 8, :UINT, 0, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "negative or zero array_size (0) cannot be given with negative bit_offset (-32)")
521
521
  end
522
522
 
523
- it "should complain with negative array_size" do
523
+ it "complains with negative array_size" do
524
524
  expect { BinaryAccessor.read_array(-32, 8, :UINT, -8, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "negative or zero array_size (-8) cannot be given with negative bit_offset (-32)")
525
525
  end
526
526
  end
527
527
 
528
- it "should complain about accessing data from a buffer which is too small" do
528
+ it "complains about accessing data from a buffer which is too small" do
529
529
  expect { BinaryAccessor.read_array(0, 256, :STRING, 256, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "16 byte buffer insufficient to read STRING at bit_offset 0 with bit_size 256")
530
530
  end
531
531
 
532
- it "should return an empty array when passed a zero length buffer" do
533
- BinaryAccessor.read_array(0, 8, :UINT, 32, "", :LITTLE_ENDIAN).should eql([])
532
+ it "returns an empty array when passed a zero length buffer" do
533
+ expect(BinaryAccessor.read_array(0, 8, :UINT, 32, "", :LITTLE_ENDIAN)).to eql([])
534
534
  end
535
535
 
536
- it "should complain about unaligned strings" do
537
- lambda { BinaryAccessor.read_array(1, 32, :STRING, 32, @data, :LITTLE_ENDIAN) }.should raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type STRING")
536
+ it "complains about unaligned strings" do
537
+ expect { BinaryAccessor.read_array(1, 32, :STRING, 32, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type STRING")
538
538
  end
539
539
 
540
- it "should read a single STRING item" do
541
- BinaryAccessor.read_array(0, 128, :STRING, 0, @data, :LITTLE_ENDIAN).should eql([@data[0..7]])
540
+ it "reads a single STRING item" do
541
+ expect(BinaryAccessor.read_array(0, 128, :STRING, 0, @data, :LITTLE_ENDIAN)).to eql([@data[0..7]])
542
542
  end
543
543
 
544
- it "should read a single BLOCK item" do
545
- BinaryAccessor.read_array(0, 128, :BLOCK, 0, @data, :LITTLE_ENDIAN).should eql([@data])
544
+ it "reads a single BLOCK item" do
545
+ expect(BinaryAccessor.read_array(0, 128, :BLOCK, 0, @data, :LITTLE_ENDIAN)).to eql([@data])
546
546
  end
547
547
 
548
- it "should read BLOCK items" do
548
+ it "reads BLOCK items" do
549
549
  data = BinaryAccessor.read_array(0, 8, :BLOCK, 0, @data, :LITTLE_ENDIAN)
550
- data.each_with_index {|val, i| val.should eql(@data[i]) }
550
+ data.each_with_index {|val, i| expect(val).to eql(@data[i]) }
551
551
  end
552
552
 
553
- it "should read 1-bit integers" do
553
+ it "reads 1-bit integers" do
554
554
  expected = [0x1, 0x0, 0x0, 0x0]
555
- BinaryAccessor.read_array(0, 1, :INT, 4, @data, :LITTLE_ENDIAN).should eql(expected)
556
- BinaryAccessor.read_array(0, 1, :INT, 2, @data, :LITTLE_ENDIAN).should eql(expected[0..1])
555
+ expect(BinaryAccessor.read_array(0, 1, :INT, 4, @data, :LITTLE_ENDIAN)).to eql(expected)
556
+ expect(BinaryAccessor.read_array(0, 1, :INT, 2, @data, :LITTLE_ENDIAN)).to eql(expected[0..1])
557
557
  end
558
558
 
559
- it "should complain about little endian bit-fields greater than 1-bit" do
559
+ it "complains about little endian bit-fields greater than 1-bit" do
560
560
  expect { BinaryAccessor.read_array(8, 7, :UINT, 21, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "read_array does not support little endian bit fields with bit_size greater than 1-bit")
561
561
  end
562
562
 
563
- it "should read 16 bit UINT items" do
563
+ it "reads 16 bit UINT items" do
564
564
  data = [0x8180, 0x8382, 0x8584, 0x8786, 0x0900, 0x0B0A, 0x0D0C, 0x0F0E]
565
- BinaryAccessor.read_array(0, 16, :UINT, 0, @data, :LITTLE_ENDIAN).should eql(data)
565
+ expect(BinaryAccessor.read_array(0, 16, :UINT, 0, @data, :LITTLE_ENDIAN)).to eql(data)
566
566
  end
567
567
 
568
- it "should read 16 bit INT items" do
568
+ it "reads 16 bit INT items" do
569
569
  data = [0x8180, 0x8382, 0x8584, 0x8786, 0x0900, 0x0B0A, 0x0D0C, 0x0F0E]
570
570
  data.map! {|x| (x & ~(1 << 15)) - (x & (1 << 15)) } # convert to negative
571
- BinaryAccessor.read_array(0, 16, :INT, 0, @data, :LITTLE_ENDIAN).should eql(data)
571
+ expect(BinaryAccessor.read_array(0, 16, :INT, 0, @data, :LITTLE_ENDIAN)).to eql(data)
572
572
  end
573
573
 
574
- it "should read 32 bit UINT items" do
574
+ it "reads 32 bit UINT items" do
575
575
  data = [0x83828180, 0x87868584, 0x0B0A0900, 0x0F0E0D0C]
576
- BinaryAccessor.read_array(0, 32, :UINT, 0, @data, :LITTLE_ENDIAN).should eql(data)
576
+ expect(BinaryAccessor.read_array(0, 32, :UINT, 0, @data, :LITTLE_ENDIAN)).to eql(data)
577
577
  end
578
578
 
579
- it "should read 32 bit INT items" do
579
+ it "reads 32 bit INT items" do
580
580
  data = [0x83828180, 0x87868584, 0x0B0A0900, 0x0F0E0D0C]
581
581
  data.map! {|x| (x & ~(1 << 31)) - (x & (1 << 31)) } # convert to negative
582
- BinaryAccessor.read_array(0, 32, :INT, 0, @data, :LITTLE_ENDIAN).should eql(data)
582
+ expect(BinaryAccessor.read_array(0, 32, :INT, 0, @data, :LITTLE_ENDIAN)).to eql(data)
583
583
  end
584
584
 
585
- it "should read 64 bit UINT items" do
585
+ it "reads 64 bit UINT items" do
586
586
  data = [0x8786858483828180, 0x0F0E0D0C0B0A0900]
587
- BinaryAccessor.read_array(0, 64, :UINT, 0, @data, :LITTLE_ENDIAN).should eql(data)
587
+ expect(BinaryAccessor.read_array(0, 64, :UINT, 0, @data, :LITTLE_ENDIAN)).to eql(data)
588
588
  end
589
589
 
590
- it "should read 64 bit INT items" do
590
+ it "reads 64 bit INT items" do
591
591
  data = [0x8786858483828180, 0x0F0E0D0C0B0A0900]
592
592
  data.map! {|x| (x & ~(1 << 63)) - (x & (1 << 63)) } # convert to negative
593
- BinaryAccessor.read_array(0, 64, :INT, 0, @data, :LITTLE_ENDIAN).should eql(data)
593
+ expect(BinaryAccessor.read_array(0, 64, :INT, 0, @data, :LITTLE_ENDIAN)).to eql(data)
594
594
  end
595
595
 
596
- it "should read aligned 32-bit floats" do
596
+ it "reads aligned 32-bit floats" do
597
597
  expected_array = [-7.670445e-037, -2.024055e-034, 2.658460e-032, 7.003653e-030]
598
598
  actual = BinaryAccessor.read_array(0, 32, :FLOAT, 0, @data, :LITTLE_ENDIAN)
599
599
  actual.each_with_index do |val, index|
600
- val.should be_within(1.0e-030).of(expected_array[index])
600
+ expect(val).to be_within(1.0e-030).of(expected_array[index])
601
601
  end
602
602
  end
603
603
 
604
- it "should read aligned 64-bit floats" do
604
+ it "reads aligned 64-bit floats" do
605
605
  expected_array = [-2.081577e-272, 3.691916e-236]
606
606
  actual = BinaryAccessor.read_array(0, 64, :FLOAT, 0, @data, :LITTLE_ENDIAN)
607
607
  actual.each_with_index do |val, index|
608
- val.should be_within(1.0e-236).of(expected_array[index])
608
+ expect(val).to be_within(1.0e-236).of(expected_array[index])
609
609
  end
610
610
  end
611
611
 
612
- it "should complain about unaligned floats" do
613
- lambda { BinaryAccessor.read_array(1, 32, :FLOAT, 32, @data, :LITTLE_ENDIAN) }.should raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type FLOAT")
612
+ it "complains about unaligned floats" do
613
+ expect { BinaryAccessor.read_array(1, 32, :FLOAT, 32, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type FLOAT")
614
614
  end
615
615
 
616
- it "should complain about mis-sized floats" do
617
- lambda { BinaryAccessor.read_array(0, 65, :FLOAT, 65, @data, :LITTLE_ENDIAN) }.should raise_error(ArgumentError, "bit_size is 65 but must be 32 or 64 for data_type FLOAT")
616
+ it "complains about mis-sized floats" do
617
+ expect { BinaryAccessor.read_array(0, 65, :FLOAT, 65, @data, :LITTLE_ENDIAN) }.to raise_error(ArgumentError, "bit_size is 65 but must be 32 or 64 for data_type FLOAT")
618
618
  end
619
619
  end # given little endian data
620
620
 
621
621
  describe "given big endian data" do
622
622
 
623
- it "should read 7-bit unsigned integers" do
623
+ it "reads 7-bit unsigned integers" do
624
624
  expected = [0x40, 0x60, 0x50]
625
625
  bit_size = 7
626
- BinaryAccessor.read_array(8, bit_size, :UINT, 21, @data, :BIG_ENDIAN).should eql(expected)
626
+ expect(BinaryAccessor.read_array(8, bit_size, :UINT, 21, @data, :BIG_ENDIAN)).to eql(expected)
627
627
  end
628
628
 
629
- it "should read 16 bit UINT items" do
629
+ it "reads 16 bit UINT items" do
630
630
  data = [0x8081, 0x8283, 0x8485, 0x8687, 0x0009, 0x0A0B, 0x0C0D, 0x0E0F]
631
- BinaryAccessor.read_array(0, 16, :UINT, 0, @data, :BIG_ENDIAN).should eql(data)
631
+ expect(BinaryAccessor.read_array(0, 16, :UINT, 0, @data, :BIG_ENDIAN)).to eql(data)
632
632
  end
633
633
 
634
- it "should read 16 bit INT items" do
634
+ it "reads 16 bit INT items" do
635
635
  data = [0x8081, 0x8283, 0x8485, 0x8687, 0x0009, 0x0A0B, 0x0C0D, 0x0E0F]
636
636
  data.map! {|x| (x & ~(1 << 15)) - (x & (1 << 15)) } # convert to negative
637
- BinaryAccessor.read_array(0, 16, :INT, 0, @data, :BIG_ENDIAN).should eql(data)
637
+ expect(BinaryAccessor.read_array(0, 16, :INT, 0, @data, :BIG_ENDIAN)).to eql(data)
638
638
  end
639
639
 
640
- it "should read 32 bit UINT items" do
640
+ it "reads 32 bit UINT items" do
641
641
  data = [0x80818283, 0x84858687, 0x00090A0B, 0x0C0D0E0F]
642
- BinaryAccessor.read_array(0, 32, :UINT, 0, @data, :BIG_ENDIAN).should eql(data)
642
+ expect(BinaryAccessor.read_array(0, 32, :UINT, 0, @data, :BIG_ENDIAN)).to eql(data)
643
643
  end
644
644
 
645
- it "should read 32 bit INT items" do
645
+ it "reads 32 bit INT items" do
646
646
  data = [0x80818283, 0x84858687, 0x00090A0B, 0x0C0D0E0F]
647
647
  data.map! {|x| (x & ~(1 << 31)) - (x & (1 << 31)) } # convert to negative
648
- BinaryAccessor.read_array(0, 32, :INT, 0, @data, :BIG_ENDIAN).should eql(data)
648
+ expect(BinaryAccessor.read_array(0, 32, :INT, 0, @data, :BIG_ENDIAN)).to eql(data)
649
649
  end
650
650
 
651
- it "should read 64 bit UINT items" do
651
+ it "reads 64 bit UINT items" do
652
652
  data = [0x8081828384858687, 0x00090A0B0C0D0E0F]
653
- BinaryAccessor.read_array(0, 64, :UINT, 0, @data, :BIG_ENDIAN).should eql(data)
653
+ expect(BinaryAccessor.read_array(0, 64, :UINT, 0, @data, :BIG_ENDIAN)).to eql(data)
654
654
  end
655
655
 
656
- it "should read 64 bit INT items" do
656
+ it "reads 64 bit INT items" do
657
657
  data = [0x8081828384858687, 0x00090A0B0C0D0E0F]
658
658
  data.map! {|x| (x & ~(1 << 63)) - (x & (1 << 63)) } # convert to negative
659
- BinaryAccessor.read_array(0, 64, :INT, 0, @data, :BIG_ENDIAN).should eql(data)
659
+ expect(BinaryAccessor.read_array(0, 64, :INT, 0, @data, :BIG_ENDIAN)).to eql(data)
660
660
  end
661
661
 
662
- it "should read aligned 32-bit floats" do
662
+ it "reads aligned 32-bit floats" do
663
663
  expected_array = [-1.189360e-038, -3.139169e-036, 8.301067e-040, 1.086646e-031]
664
664
  actual = BinaryAccessor.read_array(0, 32, :FLOAT, 0, @data, :BIG_ENDIAN)
665
665
  actual.each_with_index do |val, index|
666
- val.should be_within(1.0e-030).of(expected_array[index])
666
+ expect(val).to be_within(1.0e-030).of(expected_array[index])
667
667
  end
668
668
  end
669
669
 
670
- it "should read aligned 64-bit floats" do
670
+ it "reads aligned 64-bit floats" do
671
671
  expected_array = [-3.116851e-306, 1.257060e-308]
672
672
  actual = BinaryAccessor.read_array(0, 64, :FLOAT, 0, @data, :BIG_ENDIAN)
673
673
  actual.each_with_index do |val, index|
674
- val.should be_within(1.0e-236).of(expected_array[index])
674
+ expect(val).to be_within(1.0e-236).of(expected_array[index])
675
675
  end
676
676
  end
677
677
  end # given big endian data
@@ -684,29 +684,29 @@ module Cosmos
684
684
  @baseline_data = "\x80\x81\x82\x83\x84\x85\x86\x87\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F"
685
685
  end
686
686
 
687
- it "should complain about unrecognized data types" do
688
- lambda { BinaryAccessor.write(0, 0, 32, :BLOB, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "data_type BLOB is not recognized")
687
+ it "complains about unrecognized data types" do
688
+ expect { BinaryAccessor.write(0, 0, 32, :BLOB, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "data_type BLOB is not recognized")
689
689
  end
690
690
 
691
- it "should complain about bit_offsets before the beginning of the buffer" do
692
- lambda { BinaryAccessor.write('', -((@data.length * 8) + 8), 32, :STRING, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "#{@data.length} byte buffer insufficient to write STRING at bit_offset #{-((@data.length * 8) + 8)} with bit_size 32")
691
+ it "complains about bit_offsets before the beginning of the buffer" do
692
+ expect { BinaryAccessor.write('', -((@data.length * 8) + 8), 32, :STRING, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "#{@data.length} byte buffer insufficient to write STRING at bit_offset #{-((@data.length * 8) + 8)} with bit_size 32")
693
693
  end
694
694
 
695
- it "should complain about a negative bit_offset and zero bit_size" do
696
- lambda { BinaryAccessor.write('', -8, 0, :STRING, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "negative or zero bit_sizes (0) cannot be given with negative bit_offsets (-8)")
695
+ it "complains about a negative bit_offset and zero bit_size" do
696
+ expect { BinaryAccessor.write('', -8, 0, :STRING, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "negative or zero bit_sizes (0) cannot be given with negative bit_offsets (-8)")
697
697
  end
698
698
 
699
- it "should complain about a negative bit_offset and negative bit_size" do
700
- lambda { BinaryAccessor.write('', -8, -8, :STRING, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "negative or zero bit_sizes (-8) cannot be given with negative bit_offsets (-8)")
699
+ it "complains about a negative bit_offset and negative bit_size" do
700
+ expect { BinaryAccessor.write('', -8, -8, :STRING, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "negative or zero bit_sizes (-8) cannot be given with negative bit_offsets (-8)")
701
701
  end
702
702
 
703
- it "should complain about negative or zero bit_sizes with data_types other than STRING and BLOCK" do
704
- lambda { BinaryAccessor.write(0, 0, -8, :INT, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
705
- lambda { BinaryAccessor.write(0, 0, -8, :UINT, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
706
- lambda { BinaryAccessor.write(0, 0, -8, :FLOAT, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
703
+ it "complains about negative or zero bit_sizes with data_types other than STRING and BLOCK" do
704
+ expect { BinaryAccessor.write(0, 0, -8, :INT, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
705
+ expect { BinaryAccessor.write(0, 0, -8, :UINT, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
706
+ expect { BinaryAccessor.write(0, 0, -8, :FLOAT, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size -8 must be positive for data types other than :STRING and :BLOCK")
707
707
  end
708
708
 
709
- it "should write aligned strings" do
709
+ it "writes aligned strings" do
710
710
  0.step((@data.length - 1) * 8, 8) do |bit_offset|
711
711
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
712
712
  @expected_data = @baseline_data.clone
@@ -715,29 +715,29 @@ module Cosmos
715
715
  @expected_data[0..(first_byte_index - 1)] = "\x00" * first_byte_index
716
716
  end
717
717
  BinaryAccessor.write(@baseline_data[first_byte_index..-1], bit_offset, (@data.length * 8) - bit_offset, :STRING, @data, :BIG_ENDIAN, :ERROR)
718
- @data.should eql(@expected_data)
718
+ expect(@data).to eql(@expected_data)
719
719
  end
720
720
  end
721
721
 
722
- it "should write variable length strings with a zero and negative bit_size" do
722
+ it "writes variable length strings with a zero and negative bit_size" do
723
723
  0.step(-(@baseline_data.length * 8), -8) do |bit_size|
724
724
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
725
725
  @expected_data = @baseline_data.clone + ("\x00" * -(bit_size / 8))
726
726
  BinaryAccessor.write(@baseline_data, 0, bit_size, :STRING, @data, :BIG_ENDIAN, :ERROR)
727
- @data.should eql(@expected_data)
727
+ expect(@data).to eql(@expected_data)
728
728
  end
729
729
  end
730
730
 
731
- it "should write strings with negative bit_offsets" do
731
+ it "writes strings with negative bit_offsets" do
732
732
  BinaryAccessor.write(@baseline_data[14..15], -16, 16, :STRING, @data, :BIG_ENDIAN, :ERROR)
733
- @data.should eql(("\x00" * 14) + @baseline_data[14..15])
733
+ expect(@data).to eql(("\x00" * 14) + @baseline_data[14..15])
734
734
  end
735
735
 
736
- it "should complain about unaligned strings" do
737
- lambda { BinaryAccessor.write('', 1, 32, :STRING, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type STRING")
736
+ it "complains about unaligned strings" do
737
+ expect { BinaryAccessor.write('', 1, 32, :STRING, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type STRING")
738
738
  end
739
739
 
740
- it "should write aligned blocks" do
740
+ it "writes aligned blocks" do
741
741
  0.step((@data.length - 1) * 8, 8) do |bit_offset|
742
742
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
743
743
  @expected_data = @baseline_data.clone
@@ -746,143 +746,143 @@ module Cosmos
746
746
  @expected_data[0..(first_byte_index - 1)] = "\x00" * first_byte_index
747
747
  end
748
748
  BinaryAccessor.write(@baseline_data[first_byte_index..-1], bit_offset, (@data.length * 8) - bit_offset, :BLOCK, @data, :BIG_ENDIAN, :ERROR)
749
- @data.should eql(@expected_data)
749
+ expect(@data).to eql(@expected_data)
750
750
  end
751
751
  end
752
752
 
753
- it "should write variable length blocks with a zero and negative bit_size" do
753
+ it "writes variable length blocks with a zero and negative bit_size" do
754
754
  0.step(-(@data.length * 8), -8) do |bit_size|
755
755
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
756
756
  @expected_data = @baseline_data.clone + ("\x00" * -(bit_size / 8))
757
757
  BinaryAccessor.write(@baseline_data, 0, bit_size, :BLOCK, @data, :BIG_ENDIAN, :ERROR)
758
- @data.should eql(@expected_data)
758
+ expect(@data).to eql(@expected_data)
759
759
  end
760
760
  end
761
761
 
762
- it "should write blocks with negative bit_offsets" do
762
+ it "writes blocks with negative bit_offsets" do
763
763
  BinaryAccessor.write(@baseline_data[0..1], -16, 16, :BLOCK, @data, :BIG_ENDIAN, :ERROR)
764
- @data[-2..-1].should eql(@baseline_data[0..1])
764
+ expect(@data[-2..-1]).to eql(@baseline_data[0..1])
765
765
  end
766
766
 
767
- it "should write a blank string with zero bit size" do
767
+ it "writes a blank string with zero bit size" do
768
768
  BinaryAccessor.write('', 0, 0, :STRING, @data, :BIG_ENDIAN, :ERROR)
769
- @data.should eql('')
769
+ expect(@data).to eql('')
770
770
  end
771
771
 
772
- it "should write a blank block with zero bit size" do
772
+ it "writes a blank block with zero bit size" do
773
773
  BinaryAccessor.write('', 0, 0, :BLOCK, @data, :BIG_ENDIAN, :ERROR)
774
- @data.should eql('')
774
+ expect(@data).to eql('')
775
775
  end
776
776
 
777
- it "should write a shorter string with zero bit size" do
777
+ it "writes a shorter string with zero bit size" do
778
778
  BinaryAccessor.write("\x00\x00\x00\x00\x00\x00\x00\x00", 0, 0, :STRING, @data, :BIG_ENDIAN, :ERROR)
779
- @data.should eql("\x00\x00\x00\x00\x00\x00\x00\x00")
779
+ expect(@data).to eql("\x00\x00\x00\x00\x00\x00\x00\x00")
780
780
  end
781
781
 
782
- it "should write a shorter block with zero bit size" do
782
+ it "writes a shorter block with zero bit size" do
783
783
  BinaryAccessor.write("\x00\x00\x00\x00\x00\x00\x00\x00", 0, 0, :BLOCK, @data, :BIG_ENDIAN, :ERROR)
784
- @data.should eql("\x00\x00\x00\x00\x00\x00\x00\x00")
784
+ expect(@data).to eql("\x00\x00\x00\x00\x00\x00\x00\x00")
785
785
  end
786
786
 
787
- it "should write a shorter string and zero fill to the given bit size" do
787
+ it "writes a shorter string and zero fill to the given bit size" do
788
788
  @data = "\x80\x81\x82\x83\x84\x85\x86\x87\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F"
789
789
  BinaryAccessor.write("\x01\x02\x03\x04\x05\x06\x07\x08", 0, 128, :STRING, @data, :BIG_ENDIAN, :ERROR)
790
- @data.should eql("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00")
790
+ expect(@data).to eql("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00")
791
791
  end
792
792
 
793
- it "should write a shorter block and zero fill to the given bit size" do
793
+ it "writes a shorter block and zero fill to the given bit size" do
794
794
  @data = "\x80\x81\x82\x83\x84\x85\x86\x87\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F"
795
795
  BinaryAccessor.write("\x01\x02\x03\x04\x05\x06\x07\x08", 0, 128, :BLOCK, @data, :BIG_ENDIAN, :ERROR)
796
- @data.should eql("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00")
796
+ expect(@data).to eql("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00")
797
797
  end
798
798
 
799
- it "should complain about unaligned blocks" do
800
- lambda { BinaryAccessor.write(@baseline_data, 7, 16, :BLOCK, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_offset 7 is not byte aligned for data_type BLOCK")
799
+ it "complains about unaligned blocks" do
800
+ expect { BinaryAccessor.write(@baseline_data, 7, 16, :BLOCK, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 7 is not byte aligned for data_type BLOCK")
801
801
  end
802
802
 
803
- it "should complain if write exceeds the size of the buffer" do
804
- lambda { BinaryAccessor.write(@baseline_data, 8, 800, :STRING, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "16 byte buffer insufficient to write STRING at bit_offset 8 with bit_size 800")
803
+ it "complains if write exceeds the size of the buffer" do
804
+ expect { BinaryAccessor.write(@baseline_data, 8, 800, :STRING, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "16 byte buffer insufficient to write STRING at bit_offset 8 with bit_size 800")
805
805
  end
806
806
 
807
- it "should write aligned 8-bit unsigned integers" do
807
+ it "writes aligned 8-bit unsigned integers" do
808
808
  0.step((@data.length - 1) * 8, 8) do |bit_offset|
809
809
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
810
810
  byte_index = bit_offset / 8
811
811
  BinaryAccessor.write(@baseline_data.getbyte(byte_index), bit_offset, 8, :UINT, @data, :BIG_ENDIAN, :ERROR)
812
- @data[byte_index..byte_index].should eq(@baseline_data[byte_index..byte_index])
812
+ expect(@data[byte_index..byte_index]).to eq(@baseline_data[byte_index..byte_index])
813
813
  end
814
814
  end
815
815
 
816
- it "should write aligned 8-bit signed integers" do
816
+ it "writes aligned 8-bit signed integers" do
817
817
  0.step((@data.length - 1) * 8, 8) do |bit_offset|
818
818
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
819
819
  byte_index = bit_offset / 8
820
820
  value = @baseline_data.getbyte(byte_index)
821
821
  value = value - 256 if value >= 128
822
822
  BinaryAccessor.write(value, bit_offset, 8, :INT, @data, :BIG_ENDIAN, :ERROR)
823
- @data[byte_index..byte_index].should eql(@baseline_data[byte_index..byte_index])
823
+ expect(@data[byte_index..byte_index]).to eql(@baseline_data[byte_index..byte_index])
824
824
  end
825
825
  end
826
826
 
827
827
  describe "given big endian data" do
828
828
 
829
- it "should write 1-bit unsigned integers" do
829
+ it "writes 1-bit unsigned integers" do
830
830
  BinaryAccessor.write(0x1, 8, 1, :UINT, @data, :BIG_ENDIAN, :ERROR)
831
831
  BinaryAccessor.write(0x0, 9, 1, :UINT, @data, :BIG_ENDIAN, :ERROR)
832
832
  BinaryAccessor.write(0x1, 10, 1, :UINT, @data, :BIG_ENDIAN, :ERROR)
833
- @data.should eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
833
+ expect(@data).to eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
834
834
  end
835
835
 
836
- it "should write 1-bit signed integers" do
836
+ it "writes 1-bit signed integers" do
837
837
  BinaryAccessor.write(0x1, 8, 1, :INT, @data, :BIG_ENDIAN, :ERROR)
838
838
  BinaryAccessor.write(0x0, 9, 1, :INT, @data, :BIG_ENDIAN, :ERROR)
839
839
  BinaryAccessor.write(0x1, 10, 1, :INT, @data, :BIG_ENDIAN, :ERROR)
840
- @data.should eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
840
+ expect(@data).to eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
841
841
  end
842
842
 
843
- it "should write 7-bit unsigned integers" do
843
+ it "writes 7-bit unsigned integers" do
844
844
  BinaryAccessor.write(0x40, 8, 7, :UINT, @data, :BIG_ENDIAN, :ERROR)
845
- @data.should eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
845
+ expect(@data).to eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
846
846
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
847
847
  BinaryAccessor.write(0x20, 3, 7, :UINT, @data, :BIG_ENDIAN, :ERROR)
848
- @data.should eql("\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
848
+ expect(@data).to eql("\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
849
849
  end
850
850
 
851
- it "should write 7-bit signed integers" do
851
+ it "writes 7-bit signed integers" do
852
852
  BinaryAccessor.write(-64, 8, 7, :INT, @data, :BIG_ENDIAN, :ERROR)
853
- @data.should eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
853
+ expect(@data).to eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
854
854
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
855
855
  BinaryAccessor.write(32, 3, 7, :INT, @data, :BIG_ENDIAN, :ERROR)
856
- @data.should eql("\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
856
+ expect(@data).to eql("\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
857
857
  end
858
858
 
859
- it "should write 13-bit unsigned integers" do
859
+ it "writes 13-bit unsigned integers" do
860
860
  BinaryAccessor.write(0x1C24, 30, 13, :UINT, @data, :BIG_ENDIAN, :ERROR)
861
- @data.should eql("\x00\x00\x00\x03\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
861
+ expect(@data).to eql("\x00\x00\x00\x03\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
862
862
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
863
863
  BinaryAccessor.write(0x0020, 1, 13, :UINT, @data, :BIG_ENDIAN, :ERROR)
864
- @data.should eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
864
+ expect(@data).to eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
865
865
  end
866
866
 
867
- it "should write 13-bit signed integers" do
867
+ it "writes 13-bit signed integers" do
868
868
  BinaryAccessor.write(-988, 30, 13, :INT, @data, :BIG_ENDIAN, :ERROR)
869
- @data.should eql("\x00\x00\x00\x03\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
869
+ expect(@data).to eql("\x00\x00\x00\x03\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
870
870
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
871
871
  BinaryAccessor.write(32, 1, 13, :INT, @data, :BIG_ENDIAN, :ERROR)
872
- @data.should eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
872
+ expect(@data).to eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
873
873
  end
874
874
 
875
- it "should write aligned 16-bit unsigned integers" do
875
+ it "writes aligned 16-bit unsigned integers" do
876
876
  expected_array = [0x8081, 0x8283, 0x8485, 0x8687, 0x0009, 0x0A0B, 0x0C0D, 0x0E0F]
877
877
  index = 0
878
878
  0.step((@data.length - 1) * 8, 16) do |bit_offset|
879
879
  BinaryAccessor.write(expected_array[index], bit_offset, 16, :UINT, @data, :BIG_ENDIAN, :ERROR)
880
880
  index += 1
881
881
  end
882
- @data.should eql(@baseline_data)
882
+ expect(@data).to eql(@baseline_data)
883
883
  end
884
884
 
885
- it "should write aligned 16-bit signed integers" do
885
+ it "writes aligned 16-bit signed integers" do
886
886
  expected_array = [0x8081, 0x8283, 0x8485, 0x8687, 0x0009, 0x0A0B, 0x0C0D, 0x0E0F]
887
887
  index = 0
888
888
  0.step((@data.length - 1) * 8, 16) do |bit_offset|
@@ -891,20 +891,20 @@ module Cosmos
891
891
  BinaryAccessor.write(expected, bit_offset, 16, :INT, @data, :BIG_ENDIAN, :ERROR)
892
892
  index += 1
893
893
  end
894
- @data.should eql(@baseline_data)
894
+ expect(@data).to eql(@baseline_data)
895
895
  end
896
896
 
897
- it "should write aligned 32-bit unsigned integers" do
897
+ it "writes aligned 32-bit unsigned integers" do
898
898
  expected_array = [0x80818283, 0x84858687, 0x00090A0B, 0x0C0D0E0F]
899
899
  index = 0
900
900
  0.step((@data.length - 1) * 8, 32) do |bit_offset|
901
901
  BinaryAccessor.write(expected_array[index], bit_offset, 32, :UINT, @data, :BIG_ENDIAN, :ERROR)
902
902
  index += 1
903
903
  end
904
- @data.should eql(@baseline_data)
904
+ expect(@data).to eql(@baseline_data)
905
905
  end
906
906
 
907
- it "should write aligned 32-bit signed integers" do
907
+ it "writes aligned 32-bit signed integers" do
908
908
  expected_array = [0x80818283, 0x84858687, 0x00090A0B, 0x0C0D0E0F]
909
909
  index = 0
910
910
  0.step((@data.length - 1) * 8, 32) do |bit_offset|
@@ -913,56 +913,56 @@ module Cosmos
913
913
  BinaryAccessor.write(expected_array[index], bit_offset, 32, :INT, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
914
914
  index += 1
915
915
  end
916
- @data.should eql(@baseline_data)
916
+ expect(@data).to eql(@baseline_data)
917
917
  end
918
918
 
919
- it "should write aligned 32-bit floats" do
919
+ it "writes aligned 32-bit floats" do
920
920
  expected_array = [-1.189360e-038, -3.139169e-036, 8.301067e-040, 1.086646e-031]
921
921
  BinaryAccessor.write(expected_array[0], 0, 32, :FLOAT, @data, :BIG_ENDIAN, :ERROR)
922
922
  BinaryAccessor.write(expected_array[1], 32, 32, :FLOAT, @data, :BIG_ENDIAN, :ERROR)
923
923
  BinaryAccessor.write(expected_array[2], 64, 32, :FLOAT, @data, :BIG_ENDIAN, :ERROR)
924
924
  BinaryAccessor.write(expected_array[3], 96, 32, :FLOAT, @data, :BIG_ENDIAN, :ERROR)
925
- BinaryAccessor.read(0, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-038).of(expected_array[0])
926
- BinaryAccessor.read(32, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-036).of(expected_array[1])
927
- BinaryAccessor.read(64, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-040).of(expected_array[2])
928
- BinaryAccessor.read(96, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-031).of(expected_array[3])
925
+ expect(BinaryAccessor.read(0, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-038).of(expected_array[0])
926
+ expect(BinaryAccessor.read(32, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-036).of(expected_array[1])
927
+ expect(BinaryAccessor.read(64, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-040).of(expected_array[2])
928
+ expect(BinaryAccessor.read(96, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-031).of(expected_array[3])
929
929
  end
930
930
 
931
- it "should write 37-bit unsigned integers" do
931
+ it "writes 37-bit unsigned integers" do
932
932
  BinaryAccessor.write(0x8182838485 >> 3, 8, 37, :UINT, @data, :BIG_ENDIAN, :ERROR)
933
933
  BinaryAccessor.write(0x00090A0B0C, 67, 37, :UINT, @data, :BIG_ENDIAN, :ERROR)
934
- @data.should eql("\x00\x81\x82\x83\x84\x80\x00\x00\x00\x09\x0A\x0B\x0C\x00\x00\x00")
934
+ expect(@data).to eql("\x00\x81\x82\x83\x84\x80\x00\x00\x00\x09\x0A\x0B\x0C\x00\x00\x00")
935
935
  end
936
936
 
937
- it "should write 37-bit signed integers" do
937
+ it "writes 37-bit signed integers" do
938
938
  BinaryAccessor.write((0x8182838485 >> 3) - 2**37, 8, 37, :INT, @data, :BIG_ENDIAN, :ERROR)
939
939
  BinaryAccessor.write(0x00090A0B0C, 67, 37, :INT, @data, :BIG_ENDIAN, :ERROR)
940
- @data.should eql("\x00\x81\x82\x83\x84\x80\x00\x00\x00\x09\x0A\x0B\x0C\x00\x00\x00")
940
+ expect(@data).to eql("\x00\x81\x82\x83\x84\x80\x00\x00\x00\x09\x0A\x0B\x0C\x00\x00\x00")
941
941
  end
942
942
 
943
- it "should write 63-bit unsigned integers" do
943
+ it "writes 63-bit unsigned integers" do
944
944
  BinaryAccessor.write(0x8081828384858687 >> 1, 0, 63, :UINT, @data, :BIG_ENDIAN, :ERROR)
945
945
  BinaryAccessor.write(0x00090A0B0C0D0E0F, 65, 63, :UINT, @data, :BIG_ENDIAN, :ERROR)
946
- @data.should eql("\x80\x81\x82\x83\x84\x85\x86\x86\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F")
946
+ expect(@data).to eql("\x80\x81\x82\x83\x84\x85\x86\x86\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F")
947
947
  end
948
948
 
949
- it "should write 63-bit signed integers" do
949
+ it "writes 63-bit signed integers" do
950
950
  BinaryAccessor.write((0x8081828384858687 >> 1) - 2**63, 0, 63, :INT, @data, :BIG_ENDIAN, :ERROR)
951
951
  BinaryAccessor.write(0x00090A0B0C0D0E0F, 65, 63, :INT, @data, :BIG_ENDIAN, :ERROR)
952
- @data.should eql("\x80\x81\x82\x83\x84\x85\x86\x86\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F")
952
+ expect(@data).to eql("\x80\x81\x82\x83\x84\x85\x86\x86\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F")
953
953
  end
954
954
 
955
- it "should write aligned 64-bit unsigned integers" do
955
+ it "writes aligned 64-bit unsigned integers" do
956
956
  expected_array = [0x8081828384858687, 0x00090A0B0C0D0E0F]
957
957
  index = 0
958
958
  0.step((@data.length - 1) * 8, 64) do |bit_offset|
959
959
  BinaryAccessor.write(expected_array[index], bit_offset, 64, :UINT, @data, :BIG_ENDIAN, :ERROR)
960
960
  index += 1
961
961
  end
962
- @data.should eql(@baseline_data)
962
+ expect(@data).to eql(@baseline_data)
963
963
  end
964
964
 
965
- it "should write aligned 64-bit signed integers" do
965
+ it "writes aligned 64-bit signed integers" do
966
966
  expected_array = [0x8081828384858687, 0x00090A0B0C0D0E0F]
967
967
  index = 0
968
968
  0.step((@data.length - 1) * 8, 64) do |bit_offset|
@@ -971,90 +971,90 @@ module Cosmos
971
971
  BinaryAccessor.write(expected_array[index], bit_offset, 64, :INT, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
972
972
  index += 1
973
973
  end
974
- @data.should eql(@baseline_data)
974
+ expect(@data).to eql(@baseline_data)
975
975
  end
976
976
 
977
- it "should write aligned 64-bit floats" do
977
+ it "writes aligned 64-bit floats" do
978
978
  expected_array = [-3.116851e-306, 1.257060e-308]
979
979
  BinaryAccessor.write(expected_array[0], 0, 64, :FLOAT, @data, :BIG_ENDIAN, :ERROR)
980
980
  BinaryAccessor.write(expected_array[1], 64, 64, :FLOAT, @data, :BIG_ENDIAN, :ERROR)
981
- BinaryAccessor.read(0, 64, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-306).of(expected_array[0])
982
- BinaryAccessor.read(64, 64, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-308).of(expected_array[1])
981
+ expect(BinaryAccessor.read(0, 64, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-306).of(expected_array[0])
982
+ expect(BinaryAccessor.read(64, 64, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-308).of(expected_array[1])
983
983
  end
984
984
 
985
- it "should complain about unaligned floats" do
986
- lambda { BinaryAccessor.write(0.0, 17, 32, :FLOAT, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_offset 17 is not byte aligned for data_type FLOAT")
985
+ it "complains about unaligned floats" do
986
+ expect { BinaryAccessor.write(0.0, 17, 32, :FLOAT, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 17 is not byte aligned for data_type FLOAT")
987
987
  end
988
988
 
989
- it "should complain about mis-sized floats" do
990
- lambda { BinaryAccessor.write(0.0, 0, 33, :FLOAT, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_size is 33 but must be 32 or 64 for data_type FLOAT")
989
+ it "complains about mis-sized floats" do
990
+ expect { BinaryAccessor.write(0.0, 0, 33, :FLOAT, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size is 33 but must be 32 or 64 for data_type FLOAT")
991
991
  end
992
992
 
993
993
  end # given big endian data
994
994
 
995
995
  describe "given little endian data" do
996
996
 
997
- it "should complain about ill-defined little endian bitfields" do
998
- lambda { BinaryAccessor.write(0x1, 3, 7, :UINT, @data, :LITTLE_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "LITTLE_ENDIAN bitfield with bit_offset 3 and bit_size 7 is invalid")
997
+ it "complains about ill-defined little endian bitfields" do
998
+ expect { BinaryAccessor.write(0x1, 3, 7, :UINT, @data, :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "LITTLE_ENDIAN bitfield with bit_offset 3 and bit_size 7 is invalid")
999
999
  end
1000
1000
 
1001
- it "should write 1-bit unsigned integers" do
1001
+ it "writes 1-bit unsigned integers" do
1002
1002
  BinaryAccessor.write(0x1, 8, 1, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1003
1003
  BinaryAccessor.write(0x0, 9, 1, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1004
1004
  BinaryAccessor.write(0x1, 10, 1, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1005
- @data.should eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1005
+ expect(@data).to eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1006
1006
  end
1007
1007
 
1008
- it "should write 1-bit signed integers" do
1008
+ it "writes 1-bit signed integers" do
1009
1009
  BinaryAccessor.write(0x1, 8, 1, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1010
1010
  BinaryAccessor.write(0x0, 9, 1, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1011
1011
  BinaryAccessor.write(0x1, 10, 1, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1012
- @data.should eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1012
+ expect(@data).to eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1013
1013
  end
1014
1014
 
1015
- it "should write 7-bit unsigned integers" do
1015
+ it "writes 7-bit unsigned integers" do
1016
1016
  BinaryAccessor.write(0x40, 8, 7, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1017
- @data.should eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1017
+ expect(@data).to eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1018
1018
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1019
1019
  BinaryAccessor.write(0x7F, 11, 7, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1020
- @data.should eql("\xC0\x1F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1020
+ expect(@data).to eql("\xC0\x1F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1021
1021
  end
1022
1022
 
1023
- it "should write 7-bit signed integers" do
1023
+ it "writes 7-bit signed integers" do
1024
1024
  BinaryAccessor.write(-64, 8, 7, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1025
- @data.should eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1025
+ expect(@data).to eql("\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1026
1026
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1027
1027
  BinaryAccessor.write(32, 11, 7, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1028
- @data.should eql("\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1028
+ expect(@data).to eql("\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1029
1029
  end
1030
1030
 
1031
- it "should write 13-bit unsigned integers" do
1031
+ it "writes 13-bit unsigned integers" do
1032
1032
  BinaryAccessor.write(0x1C24, 30, 13, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1033
- @data.should eql("\x00\x80\x84\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1033
+ expect(@data).to eql("\x00\x80\x84\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1034
1034
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1035
1035
  BinaryAccessor.write(0x0020, 9, 13, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1036
- @data.should eql("\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1036
+ expect(@data).to eql("\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1037
1037
  end
1038
1038
 
1039
- it "should write 13-bit signed integers" do
1039
+ it "writes 13-bit signed integers" do
1040
1040
  BinaryAccessor.write(-988, 30, 13, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1041
- @data.should eql("\x00\x80\x84\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1041
+ expect(@data).to eql("\x00\x80\x84\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1042
1042
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1043
1043
  BinaryAccessor.write(32, 9, 13, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1044
- @data.should eql("\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1044
+ expect(@data).to eql("\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1045
1045
  end
1046
1046
 
1047
- it "should write aligned 16-bit unsigned integers" do
1047
+ it "writes aligned 16-bit unsigned integers" do
1048
1048
  expected_array = [0x8180, 0x8382, 0x8584, 0x8786, 0x0900, 0x0B0A, 0x0D0C, 0x0F0E]
1049
1049
  index = 0
1050
1050
  0.step((@data.length - 1) * 8, 16) do |bit_offset|
1051
1051
  BinaryAccessor.write(expected_array[index], bit_offset, 16, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1052
1052
  index += 1
1053
1053
  end
1054
- @data.should eql(@baseline_data)
1054
+ expect(@data).to eql(@baseline_data)
1055
1055
  end
1056
1056
 
1057
- it "should write aligned 16-bit signed integers" do
1057
+ it "writes aligned 16-bit signed integers" do
1058
1058
  expected_array = [0x8180, 0x8382, 0x8584, 0x8786, 0x0900, 0x0B0A, 0x0D0C, 0x0F0E]
1059
1059
  index = 0
1060
1060
  0.step((@data.length - 1) * 8, 16) do |bit_offset|
@@ -1063,20 +1063,20 @@ module Cosmos
1063
1063
  BinaryAccessor.write(expected, bit_offset, 16, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1064
1064
  index += 1
1065
1065
  end
1066
- @data.should eql(@baseline_data)
1066
+ expect(@data).to eql(@baseline_data)
1067
1067
  end
1068
1068
 
1069
- it "should write aligned 32-bit unsigned integers" do
1069
+ it "writes aligned 32-bit unsigned integers" do
1070
1070
  expected_array = [0x83828180, 0x87868584, 0x0B0A0900, 0x0F0E0D0C]
1071
1071
  index = 0
1072
1072
  0.step((@data.length - 1) * 8, 32) do |bit_offset|
1073
1073
  BinaryAccessor.write(expected_array[index], bit_offset, 32, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1074
1074
  index += 1
1075
1075
  end
1076
- @data.should eql(@baseline_data)
1076
+ expect(@data).to eql(@baseline_data)
1077
1077
  end
1078
1078
 
1079
- it "should write aligned 32-bit signed integers" do
1079
+ it "writes aligned 32-bit signed integers" do
1080
1080
  expected_array = [0x83828180, 0x87868584, 0x0B0A0900, 0x0F0E0D0C]
1081
1081
  index = 0
1082
1082
  0.step((@data.length - 1) * 8, 32) do |bit_offset|
@@ -1085,56 +1085,56 @@ module Cosmos
1085
1085
  BinaryAccessor.write(expected_array[index], bit_offset, 32, :INT, @data, :LITTLE_ENDIAN, :ERROR_ALLOW_HEX)
1086
1086
  index += 1
1087
1087
  end
1088
- @data.should eql(@baseline_data)
1088
+ expect(@data).to eql(@baseline_data)
1089
1089
  end
1090
1090
 
1091
- it "should write aligned 32-bit floats" do
1091
+ it "writes aligned 32-bit floats" do
1092
1092
  expected_array = [-7.670445e-037, -2.024055e-034, 2.658460e-032, 7.003653e-030]
1093
1093
  BinaryAccessor.write(expected_array[0], 0, 32, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR)
1094
1094
  BinaryAccessor.write(expected_array[1], 32, 32, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR)
1095
1095
  BinaryAccessor.write(expected_array[2], 64, 32, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR)
1096
1096
  BinaryAccessor.write(expected_array[3], 96, 32, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR)
1097
- BinaryAccessor.read(0, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-037).of(expected_array[0])
1098
- BinaryAccessor.read(32, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-034).of(expected_array[1])
1099
- BinaryAccessor.read(64, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-032).of(expected_array[2])
1100
- BinaryAccessor.read(96, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-030).of(expected_array[3])
1097
+ expect(BinaryAccessor.read(0, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-037).of(expected_array[0])
1098
+ expect(BinaryAccessor.read(32, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-034).of(expected_array[1])
1099
+ expect(BinaryAccessor.read(64, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-032).of(expected_array[2])
1100
+ expect(BinaryAccessor.read(96, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-030).of(expected_array[3])
1101
1101
  end
1102
1102
 
1103
- it "should write 37-bit unsigned integers" do
1103
+ it "writes 37-bit unsigned integers" do
1104
1104
  BinaryAccessor.write(0x1584838281, 43, 37, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1105
1105
  BinaryAccessor.write(0x0C0B0A0900 >> 3, 96, 37, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1106
- @data.should eql("\x00\x81\x82\x83\x84\x15\x00\x00\x00\x09\x0A\x0B\x0C\x00\x00\x00")
1106
+ expect(@data).to eql("\x00\x81\x82\x83\x84\x15\x00\x00\x00\x09\x0A\x0B\x0C\x00\x00\x00")
1107
1107
  end
1108
1108
 
1109
- it "should write 37-bit signed integers" do
1109
+ it "writes 37-bit signed integers" do
1110
1110
  BinaryAccessor.write(0x1584838281 - 2**37, 43, 37, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1111
1111
  BinaryAccessor.write(0x0C0B0A0900 >> 3, 96, 37, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1112
- @data.should eql("\x00\x81\x82\x83\x84\x15\x00\x00\x00\x09\x0A\x0B\x0C\x00\x00\x00")
1112
+ expect(@data).to eql("\x00\x81\x82\x83\x84\x15\x00\x00\x00\x09\x0A\x0B\x0C\x00\x00\x00")
1113
1113
  end
1114
1114
 
1115
- it "should write 63-bit unsigned integers" do
1115
+ it "writes 63-bit unsigned integers" do
1116
1116
  BinaryAccessor.write(0x4786858483828180, 57, 63, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1117
1117
  BinaryAccessor.write(0x0F0E0D0C0B0A0900 >> 1, 120, 63, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1118
- @data.should eql("\x80\x81\x82\x83\x84\x85\x86\x47\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F")
1118
+ expect(@data).to eql("\x80\x81\x82\x83\x84\x85\x86\x47\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F")
1119
1119
  end
1120
1120
 
1121
- it "should write 63-bit signed integers" do
1121
+ it "writes 63-bit signed integers" do
1122
1122
  BinaryAccessor.write(0x4786858483828180 - 2**63, 57, 63, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1123
1123
  BinaryAccessor.write(0x0F0E0D0C0B0A0900 >> 1, 120, 63, :INT, @data, :LITTLE_ENDIAN, :ERROR)
1124
- @data.should eql("\x80\x81\x82\x83\x84\x85\x86\x47\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F")
1124
+ expect(@data).to eql("\x80\x81\x82\x83\x84\x85\x86\x47\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F")
1125
1125
  end
1126
1126
 
1127
- it "should write aligned 64-bit unsigned integers" do
1127
+ it "writes aligned 64-bit unsigned integers" do
1128
1128
  expected_array = [0x8786858483828180, 0x0F0E0D0C0B0A0900]
1129
1129
  index = 0
1130
1130
  0.step((@data.length - 1) * 8, 64) do |bit_offset|
1131
1131
  BinaryAccessor.write(expected_array[index], bit_offset, 64, :UINT, @data, :LITTLE_ENDIAN, :ERROR)
1132
1132
  index += 1
1133
1133
  end
1134
- @data.should eql(@baseline_data)
1134
+ expect(@data).to eql(@baseline_data)
1135
1135
  end
1136
1136
 
1137
- it "should write aligned 64-bit signed integers" do
1137
+ it "writes aligned 64-bit signed integers" do
1138
1138
  expected_array = [0x8786858483828180, 0x0F0E0D0C0B0A0900]
1139
1139
  index = 0
1140
1140
  0.step((@data.length - 1) * 8, 64) do |bit_offset|
@@ -1143,23 +1143,23 @@ module Cosmos
1143
1143
  BinaryAccessor.write(expected_array[index], bit_offset, 64, :INT, @data, :LITTLE_ENDIAN, :ERROR_ALLOW_HEX)
1144
1144
  index += 1
1145
1145
  end
1146
- @data.should eql(@baseline_data)
1146
+ expect(@data).to eql(@baseline_data)
1147
1147
  end
1148
1148
 
1149
- it "should write aligned 64-bit floats" do
1149
+ it "writes aligned 64-bit floats" do
1150
1150
  expected_array = [-2.081577e-272, 3.691916e-236]
1151
1151
  BinaryAccessor.write(expected_array[0], 0, 64, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR)
1152
1152
  BinaryAccessor.write(expected_array[1], 64, 64, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR)
1153
- BinaryAccessor.read(0, 64, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-272).of(expected_array[0])
1154
- BinaryAccessor.read(64, 64, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-236).of(expected_array[1])
1153
+ expect(BinaryAccessor.read(0, 64, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-272).of(expected_array[0])
1154
+ expect(BinaryAccessor.read(64, 64, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-236).of(expected_array[1])
1155
1155
  end
1156
1156
 
1157
- it "should complain about unaligned floats" do
1158
- lambda { BinaryAccessor.write(0.0, 1, 32, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type FLOAT")
1157
+ it "complains about unaligned floats" do
1158
+ expect { BinaryAccessor.write(0.0, 1, 32, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type FLOAT")
1159
1159
  end
1160
1160
 
1161
- it "should complain about mis-sized floats" do
1162
- lambda { BinaryAccessor.write(0.0, 0, 65, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_size is 65 but must be 32 or 64 for data_type FLOAT")
1161
+ it "complains about mis-sized floats" do
1162
+ expect { BinaryAccessor.write(0.0, 0, 65, :FLOAT, @data, :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size is 65 but must be 32 or 64 for data_type FLOAT")
1163
1163
  end
1164
1164
 
1165
1165
  end # given little endian data
@@ -1169,272 +1169,272 @@ module Cosmos
1169
1169
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1170
1170
  end
1171
1171
 
1172
- it "should prevent overflow of STRING" do
1173
- lambda { BinaryAccessor.write("abcde", 0, 32, :STRING, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of 5 bytes does not fit into 4 bytes for data_type STRING")
1172
+ it "prevents overflow of STRING" do
1173
+ expect { BinaryAccessor.write("abcde", 0, 32, :STRING, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of 5 bytes does not fit into 4 bytes for data_type STRING")
1174
1174
  end
1175
1175
 
1176
- it "should prevent overflow of BLOCK" do
1177
- lambda { BinaryAccessor.write("abcde", 0, 32, :BLOCK, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of 5 bytes does not fit into 4 bytes for data_type BLOCK")
1176
+ it "prevents overflow of BLOCK" do
1177
+ expect { BinaryAccessor.write("abcde", 0, 32, :BLOCK, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of 5 bytes does not fit into 4 bytes for data_type BLOCK")
1178
1178
  end
1179
1179
 
1180
- it "should prevent overflow of 8-bit INT" do
1180
+ it "prevents overflow of 8-bit INT" do
1181
1181
  bit_size = 8; data_type = :INT; value = 2 ** (bit_size - 1)
1182
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1182
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1183
1183
  value = -(value + 1)
1184
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1184
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1185
1185
  end
1186
1186
 
1187
- it "should prevent overflow of 16-bit INT" do
1187
+ it "prevents overflow of 16-bit INT" do
1188
1188
  bit_size = 16; data_type = :INT; value = 2 ** (bit_size - 1)
1189
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1189
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1190
1190
  value = -(value + 1)
1191
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1191
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1192
1192
  end
1193
1193
 
1194
- it "should prevent overflow of 32-bit INT" do
1194
+ it "prevents overflow of 32-bit INT" do
1195
1195
  bit_size = 32; data_type = :INT; value = 2 ** (bit_size - 1)
1196
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1196
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1197
1197
  value = -(value + 1)
1198
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1198
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1199
1199
  end
1200
1200
 
1201
- it "should prevent overflow of 64-bit INT" do
1201
+ it "prevents overflow of 64-bit INT" do
1202
1202
  bit_size = 64; data_type = :INT; value = 2 ** (bit_size - 1)
1203
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1203
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1204
1204
  value = -(value + 1)
1205
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1205
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1206
1206
  end
1207
1207
 
1208
- it "should prevent overflow of 3-bit INT" do
1208
+ it "prevents overflow of 3-bit INT" do
1209
1209
  bit_size = 3; data_type = :INT; value = 2 ** (bit_size - 1)
1210
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1210
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1211
1211
  value = -(value + 1)
1212
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1212
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1213
1213
  end
1214
1214
 
1215
- it "should prevent overflow of 8-bit UINT" do
1215
+ it "prevents overflow of 8-bit UINT" do
1216
1216
  bit_size = 8; data_type = :UINT; value = 2 ** bit_size
1217
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1217
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1218
1218
  value = -1
1219
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1219
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1220
1220
  end
1221
1221
 
1222
- it "should prevent overflow of 16-bit UINT" do
1222
+ it "prevents overflow of 16-bit UINT" do
1223
1223
  bit_size = 16; data_type = :UINT; value = 2 ** bit_size
1224
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1224
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1225
1225
  value = -1
1226
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1226
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1227
1227
  end
1228
1228
 
1229
- it "should prevent overflow of 32-bit UINT" do
1229
+ it "prevents overflow of 32-bit UINT" do
1230
1230
  bit_size = 32; data_type = :UINT; value = 2 ** bit_size
1231
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1231
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1232
1232
  value = -1
1233
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1233
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1234
1234
  end
1235
1235
 
1236
- it "should prevent overflow of 64-bit UINT" do
1236
+ it "prevents overflow of 64-bit UINT" do
1237
1237
  bit_size = 64; data_type = :UINT; value = 2 ** bit_size
1238
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1238
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1239
1239
  value = -1
1240
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1240
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1241
1241
  end
1242
1242
 
1243
- it "should prevent overflow of 3-bit UINT" do
1243
+ it "prevents overflow of 3-bit UINT" do
1244
1244
  bit_size = 3; data_type = :UINT; value = 2 ** bit_size
1245
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1245
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1246
1246
  value = -1
1247
- lambda { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1247
+ expect { BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1248
1248
  end
1249
1249
 
1250
- it "should truncate STRING" do
1250
+ it "truncates STRING" do
1251
1251
  BinaryAccessor.write("abcde", 0, 32, :STRING, @data, :BIG_ENDIAN, :TRUNCATE)
1252
- @data[0..4].should eql "abcd\x00"
1252
+ expect(@data[0..4]).to eql "abcd\x00"
1253
1253
  end
1254
1254
 
1255
- it "should truncate BLOCK" do
1255
+ it "truncates BLOCK" do
1256
1256
  BinaryAccessor.write("abcde", 0, 32, :BLOCK, @data, :BIG_ENDIAN, :TRUNCATE)
1257
- @data[0..4].should eql "abcd\x00"
1257
+ expect(@data[0..4]).to eql "abcd\x00"
1258
1258
  end
1259
1259
 
1260
- it "should truncate 8-bit INT" do
1260
+ it "truncates 8-bit INT" do
1261
1261
  bit_size = 8; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1262
1262
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1263
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1263
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1264
1264
  end
1265
1265
 
1266
- it "should truncate 16-bit INT" do
1266
+ it "truncates 16-bit INT" do
1267
1267
  bit_size = 16; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1268
1268
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1269
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1269
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1270
1270
  end
1271
1271
 
1272
- it "should truncate 32-bit INT" do
1272
+ it "truncates 32-bit INT" do
1273
1273
  bit_size = 32; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1274
1274
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1275
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1275
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1276
1276
  end
1277
1277
 
1278
- it "should truncate 64-bit INT" do
1278
+ it "truncates 64-bit INT" do
1279
1279
  bit_size = 64; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1280
1280
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1281
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1281
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1282
1282
  end
1283
1283
 
1284
- it "should truncate 3-bit INT" do
1284
+ it "truncates 3-bit INT" do
1285
1285
  bit_size = 3; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1286
1286
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1287
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1287
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1288
1288
  end
1289
1289
 
1290
- it "should truncate 8-bit UINT" do
1290
+ it "truncates 8-bit UINT" do
1291
1291
  bit_size = 8; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1292
1292
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1293
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1293
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1294
1294
  end
1295
1295
 
1296
- it "should truncate 16-bit UINT" do
1296
+ it "truncates 16-bit UINT" do
1297
1297
  bit_size = 16; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1298
1298
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1299
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1299
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1300
1300
  end
1301
1301
 
1302
- it "should truncate 32-bit UINT" do
1302
+ it "truncates 32-bit UINT" do
1303
1303
  bit_size = 32; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1304
1304
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1305
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1305
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1306
1306
  end
1307
1307
 
1308
- it "should truncate 64-bit UINT" do
1308
+ it "truncates 64-bit UINT" do
1309
1309
  bit_size = 64; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1310
1310
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1311
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1311
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1312
1312
  end
1313
1313
 
1314
- it "should truncate 3-bit UINT" do
1314
+ it "truncates 3-bit UINT" do
1315
1315
  bit_size = 3; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1316
1316
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :TRUNCATE)
1317
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1317
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1318
1318
  end
1319
1319
 
1320
- it "should saturate 8-bit INT" do
1320
+ it "saturates 8-bit INT" do
1321
1321
  bit_size = 8; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1322
1322
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1323
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1323
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1324
1324
  value = -(value + 1); saturated_value = value + 1
1325
1325
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1326
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1326
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1327
1327
  end
1328
1328
 
1329
- it "should saturate 16-bit INT" do
1329
+ it "saturates 16-bit INT" do
1330
1330
  bit_size = 16; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1331
1331
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1332
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1332
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1333
1333
  value = -(value + 1); saturated_value = value + 1
1334
1334
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1335
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1335
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1336
1336
  end
1337
1337
 
1338
- it "should saturate 32-bit INT" do
1338
+ it "saturates 32-bit INT" do
1339
1339
  bit_size = 32; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1340
1340
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1341
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1341
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1342
1342
  value = -(value + 1); saturated_value = value + 1
1343
1343
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1344
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1344
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1345
1345
  end
1346
1346
 
1347
- it "should saturate 64-bit INT" do
1347
+ it "saturates 64-bit INT" do
1348
1348
  bit_size = 64; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1349
1349
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1350
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1350
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1351
1351
  value = -(value + 1); saturated_value = value + 1
1352
1352
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1353
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1353
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1354
1354
  end
1355
1355
 
1356
- it "should saturate 3-bit INT" do
1356
+ it "saturates 3-bit INT" do
1357
1357
  bit_size = 3; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1358
1358
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1359
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1359
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1360
1360
  value = -(value + 1); saturated_value = value + 1
1361
1361
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1362
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1362
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1363
1363
  end
1364
1364
 
1365
- it "should saturate 8-bit UINT" do
1365
+ it "saturates 8-bit UINT" do
1366
1366
  bit_size = 8; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
1367
1367
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1368
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1368
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1369
1369
  value = -1; saturated_value = 0
1370
1370
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1371
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1371
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1372
1372
  end
1373
1373
 
1374
- it "should saturate 16-bit UINT" do
1374
+ it "saturates 16-bit UINT" do
1375
1375
  bit_size = 16; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
1376
1376
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1377
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1377
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1378
1378
  value = -1; saturated_value = 0
1379
1379
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1380
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1380
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1381
1381
  end
1382
1382
 
1383
- it "should saturate 32-bit UINT" do
1383
+ it "saturates 32-bit UINT" do
1384
1384
  bit_size = 32; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
1385
1385
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1386
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1386
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1387
1387
  value = -1; saturated_value = 0
1388
1388
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1389
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1389
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1390
1390
  end
1391
1391
 
1392
- it "should saturate 64-bit UINT" do
1392
+ it "saturates 64-bit UINT" do
1393
1393
  bit_size = 64; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
1394
1394
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1395
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1395
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1396
1396
  value = -1; saturated_value = 0
1397
1397
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1398
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1398
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1399
1399
  end
1400
1400
 
1401
- it "should saturate 3-bit UINT" do
1401
+ it "saturates 3-bit UINT" do
1402
1402
  bit_size = 3; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
1403
1403
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1404
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1404
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1405
1405
  value = -1; saturated_value = 0
1406
1406
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :SATURATE)
1407
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1407
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1408
1408
  end
1409
1409
 
1410
- it "should allow hex value entry of 8-bit INT" do
1410
+ it "allows hex value entry of 8-bit INT" do
1411
1411
  bit_size = 8; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
1412
1412
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
1413
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
1413
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
1414
1414
  end
1415
1415
 
1416
- it "should allow hex value entry of 16-bit INT" do
1416
+ it "allows hex value entry of 16-bit INT" do
1417
1417
  bit_size = 16; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
1418
1418
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
1419
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
1419
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
1420
1420
  end
1421
1421
 
1422
- it "should allow hex value entry of 32-bit INT" do
1422
+ it "allows hex value entry of 32-bit INT" do
1423
1423
  bit_size = 32; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
1424
1424
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
1425
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
1425
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
1426
1426
  end
1427
1427
 
1428
- it "should allow hex value entry of 64-bit INT" do
1428
+ it "allows hex value entry of 64-bit INT" do
1429
1429
  bit_size = 64; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
1430
1430
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
1431
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
1431
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
1432
1432
  end
1433
1433
 
1434
- it "should allow hex value entry of 3-bit INT" do
1434
+ it "allows hex value entry of 3-bit INT" do
1435
1435
  bit_size = 3; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
1436
1436
  BinaryAccessor.write(value, 0, bit_size, data_type, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
1437
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
1437
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
1438
1438
  end
1439
1439
 
1440
1440
  end
@@ -1451,392 +1451,392 @@ module Cosmos
1451
1451
  @baseline_data.length.times {|i| @baseline_data_array << @baseline_data[i] }
1452
1452
  end
1453
1453
 
1454
- it "should complain about value other than Array" do
1455
- lambda { BinaryAccessor.write_array("", 0, 32, :STRING, 0, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "values must be an Array type class is String")
1454
+ it "complains about value other than Array" do
1455
+ expect { BinaryAccessor.write_array("", 0, 32, :STRING, 0, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "values must be an Array type class is String")
1456
1456
  end
1457
1457
 
1458
- it "should complain about unrecognized data types" do
1459
- lambda { BinaryAccessor.write_array([0], 0, 32, :BLOB, 0, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "data_type BLOB is not recognized")
1458
+ it "complains about unrecognized data types" do
1459
+ expect { BinaryAccessor.write_array([0], 0, 32, :BLOB, 0, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "data_type BLOB is not recognized")
1460
1460
  end
1461
1461
 
1462
- it "should complain about bit_offsets before the beginning of the buffer" do
1462
+ it "complains about bit_offsets before the beginning of the buffer" do
1463
1463
  expect { BinaryAccessor.write_array([''], -((@data.length * 8) + 8), 32, :STRING, 0, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "#{@data.length} byte buffer insufficient to write STRING at bit_offset #{-((@data.length * 8) + 8)} with bit_size 32")
1464
1464
  end
1465
1465
 
1466
- it "should write if a negative bit_offset is equal to length of buffer" do
1466
+ it "writes if a negative bit_offset is equal to length of buffer" do
1467
1467
  BinaryAccessor.write_array(@baseline_data_array, -(@data.length * 8), 8, :BLOCK, @baseline_data_array.length*8, @data, :BIG_ENDIAN, :ERROR)
1468
- @data.should eql @baseline_data
1468
+ expect(@data).to eql @baseline_data
1469
1469
  end
1470
1470
 
1471
- it "should complain about a negative or zero bit_size" do
1471
+ it "complains about a negative or zero bit_size" do
1472
1472
  expect { BinaryAccessor.write_array([''], 0, 0, :STRING, 0, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size 0 must be positive for arrays")
1473
1473
  expect { BinaryAccessor.write_array([''], 0, -8, :STRING, 0, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size -8 must be positive for arrays")
1474
1474
  end
1475
1475
 
1476
- it "should write aligned strings with fixed array_size" do
1476
+ it "writes aligned strings with fixed array_size" do
1477
1477
  data = @data.clone
1478
1478
  BinaryAccessor.write_array(@baseline_data_array, 0, 8, :STRING, @baseline_data_array.length*8, data, :BIG_ENDIAN, :ERROR)
1479
- data.should eql(@baseline_data)
1479
+ expect(data).to eql(@baseline_data)
1480
1480
  end
1481
1481
 
1482
- it "should write aligned strings with zero array_size" do
1482
+ it "writes aligned strings with zero array_size" do
1483
1483
  BinaryAccessor.write_array(@baseline_data_array, 0, 8, :STRING, 0, @data, :BIG_ENDIAN, :ERROR)
1484
- @data.should eql(@baseline_data)
1484
+ expect(@data).to eql(@baseline_data)
1485
1485
  end
1486
1486
 
1487
- it "should write strings with negative bit_offsets" do
1487
+ it "writes strings with negative bit_offsets" do
1488
1488
  BinaryAccessor.write_array(@baseline_data_array[14..15], -16, 8, :STRING, 16, @data, :BIG_ENDIAN, :ERROR)
1489
- @data.should eql(("\x00" * 14) + @baseline_data[14..15])
1489
+ expect(@data).to eql(("\x00" * 14) + @baseline_data[14..15])
1490
1490
  end
1491
1491
 
1492
- it "should complain about unaligned strings" do
1492
+ it "complains about unaligned strings" do
1493
1493
  expect { BinaryAccessor.write_array([], 1, 32, :STRING, 32, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type STRING")
1494
1494
  end
1495
1495
 
1496
- it "should complain if pass more values than the given array_size can hold" do
1496
+ it "complains if pass more values than the given array_size can hold" do
1497
1497
  expect { BinaryAccessor.write_array(@baseline_data_array, 0, 8, :BLOCK, 32, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "too many values #{@baseline_data_array.length} for given array_size 32 and bit_size 8")
1498
1498
  end
1499
1499
 
1500
- it "should write blocks with fixed array_size" do
1500
+ it "writes blocks with fixed array_size" do
1501
1501
  BinaryAccessor.write_array(@baseline_data_array, 0, 8, :BLOCK, @baseline_data_array.length*8, @data, :BIG_ENDIAN, :ERROR)
1502
- @data.should eql(@baseline_data)
1502
+ expect(@data).to eql(@baseline_data)
1503
1503
  end
1504
1504
 
1505
- it "should zero fill if array_size > number of values passed" do
1505
+ it "zeros fill if array_size > number of values passed" do
1506
1506
  data = @baseline_data.clone
1507
1507
  BinaryAccessor.write_array(["\x01","\x02","\x03","\x04"], 0, 8, :BLOCK, 64, @baseline_data, :BIG_ENDIAN, :ERROR)
1508
- @baseline_data.should eql("\x01\x02\x03\x04" + "\x00" * 4 + data[8..-1])
1508
+ expect(@baseline_data).to eql("\x01\x02\x03\x04" + "\x00" * 4 + data[8..-1])
1509
1509
  end
1510
1510
 
1511
- it "should write blocks with fixed array_size at non zero offset" do
1511
+ it "writes blocks with fixed array_size at non zero offset" do
1512
1512
  BinaryAccessor.write_array(@baseline_data_array[0..-5], 32, 8, :BLOCK, @baseline_data_array.length*8-32, @data, :BIG_ENDIAN, :ERROR)
1513
- @data.should eql(("\x00" * 4) + @baseline_data[0..-5])
1513
+ expect(@data).to eql(("\x00" * 4) + @baseline_data[0..-5])
1514
1514
  end
1515
1515
 
1516
- it "should write blocks with zero array_size" do
1516
+ it "writes blocks with zero array_size" do
1517
1517
  BinaryAccessor.write_array(@baseline_data_array, 0, 8, :BLOCK, 0, @data, :BIG_ENDIAN, :ERROR)
1518
- @data.should eql(@baseline_data)
1518
+ expect(@data).to eql(@baseline_data)
1519
1519
  end
1520
1520
 
1521
- it "should write blocks with negative bit_offsets" do
1521
+ it "writes blocks with negative bit_offsets" do
1522
1522
  BinaryAccessor.write_array(["\x80\x81","\x82\x83"], -32, 16, :BLOCK, 32, @data, :BIG_ENDIAN, :ERROR)
1523
- @data.should eql(("\x00" * 12) + @baseline_data[0..3])
1523
+ expect(@data).to eql(("\x00" * 12) + @baseline_data[0..3])
1524
1524
  end
1525
1525
 
1526
- it "should complain with an array_size not a multiple of bit_size" do
1526
+ it "complains with an array_size not a multiple of bit_size" do
1527
1527
  data = @data.unpack('C*')
1528
1528
  expect { BinaryAccessor.write_array([1,2], 0, 8, :UINT, 10, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "array_size 10 not a multiple of bit_size 8")
1529
1529
  end
1530
1530
 
1531
- it "should complain with an array_size not a multiple of bit_size" do
1531
+ it "complains with an array_size not a multiple of bit_size" do
1532
1532
  data = @data.unpack('C*')
1533
1533
  expect { BinaryAccessor.write_array([1,2], 0, 8, :UINT, -10, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "array_size -10 not a multiple of bit_size 8")
1534
1534
  end
1535
1535
 
1536
- it "should exclude the remaining bits if array_size is negative" do
1536
+ it "excludes the remaining bits if array_size is negative" do
1537
1537
  data = @data.clone
1538
1538
  BinaryAccessor.write_array(@baseline_data_array[0..-5], 0, 8, :BLOCK, -32, @data, :BIG_ENDIAN, :ERROR)
1539
- @data.should eql(@baseline_data[0..-5] + data[-4..-1])
1539
+ expect(@data).to eql(@baseline_data[0..-5] + data[-4..-1])
1540
1540
  end
1541
1541
 
1542
- it "should not write if the offset equals the negative array size" do
1542
+ it "does not write if the offset equals the negative array size" do
1543
1543
  data = @data.clone
1544
1544
  BinaryAccessor.write_array([], @data.length*8-32, 8, :BLOCK, -32, @data, :LITTLE_ENDIAN, :ERROR)
1545
- @data.should eql(data)
1545
+ expect(@data).to eql(data)
1546
1546
  end
1547
1547
 
1548
- it "should expand the buffer to handle negative array size" do
1548
+ it "expands the buffer to handle negative array size" do
1549
1549
  @data = "\x00\x01\x02\x00\x03"
1550
1550
  BinaryAccessor.write_array([1,2,3,4], 0, 32, :UINT, -8, @data, :BIG_ENDIAN, :ERROR)
1551
- @data.should eql("\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x03")
1551
+ expect(@data).to eql("\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x03")
1552
1552
  end
1553
1553
 
1554
- it "should shrink the buffer when handling negative array size" do
1554
+ it "shrinks the buffer when handling negative array size" do
1555
1555
  # Start with one array item
1556
1556
  @data = "\x00\x01\x02\x00\x03"
1557
1557
  # Goto 4 array items array item
1558
1558
  BinaryAccessor.write_array([1,2,3,4], 0, 32, :UINT, -8, @data, :BIG_ENDIAN, :ERROR)
1559
- @data.should eql("\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x03")
1559
+ expect(@data).to eql("\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x03")
1560
1560
  # Goto 2 array items
1561
1561
  BinaryAccessor.write_array([1,2], 0, 32, :UINT, -8, @data, :BIG_ENDIAN, :ERROR)
1562
- @data.should eql("\x00\x00\x00\x01\x00\x00\x00\x02\x03")
1562
+ expect(@data).to eql("\x00\x00\x00\x01\x00\x00\x00\x02\x03")
1563
1563
  # Goto 0 array items
1564
1564
  BinaryAccessor.write_array([], 0, 32, :UINT, -8, @data, :BIG_ENDIAN, :ERROR)
1565
- @data.should eql("\x03")
1565
+ expect(@data).to eql("\x03")
1566
1566
  # Go back to 1 array items
1567
1567
  BinaryAccessor.write_array([1], 0, 32, :UINT, -8, @data, :BIG_ENDIAN, :ERROR)
1568
- @data.should eql("\x00\x00\x00\x01\x03")
1568
+ expect(@data).to eql("\x00\x00\x00\x01\x03")
1569
1569
  end
1570
1570
 
1571
1571
  it "complain when passed a zero length buffer" do
1572
1572
  expect { BinaryAccessor.write_array([1,2,3], 0, 8, :UINT, 32, "", :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError)
1573
1573
  end
1574
1574
 
1575
- it "should expand the buffer if the offset is greater than the negative array size" do
1575
+ it "expands the buffer if the offset is greater than the negative array size" do
1576
1576
  offset = @data.length * 8 - 16
1577
1577
  data = @data.clone
1578
1578
  BinaryAccessor.write_array([1,2], offset, 8, :UINT, -32, @data, :LITTLE_ENDIAN, :ERROR)
1579
- @data.should eql(data[0..-3] + "\x01\x02" + data[-4..-1])
1579
+ expect(@data).to eql(data[0..-3] + "\x01\x02" + data[-4..-1])
1580
1580
  end
1581
1581
 
1582
- it "should complain with negative bit_offset and zero array_size" do
1582
+ it "complains with negative bit_offset and zero array_size" do
1583
1583
  expect { BinaryAccessor.write_array([1,2], -32, 8, :UINT, 0, @data, :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "negative or zero array_size (0) cannot be given with negative bit_offset (-32)")
1584
1584
  end
1585
1585
 
1586
- it "should complain with negative array_size" do
1586
+ it "complains with negative array_size" do
1587
1587
  expect { BinaryAccessor.write_array([1,2], -32, 8, :UINT, -8, @data, :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "negative or zero array_size (-8) cannot be given with negative bit_offset (-32)")
1588
1588
  end
1589
1589
 
1590
- it "should write a shorter string and zero fill to the given bit size" do
1590
+ it "writes a shorter string and zero fill to the given bit size" do
1591
1591
  @data = "\x80\x81\x82\x83\x84\x85\x86\x87\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F"
1592
1592
  BinaryAccessor.write_array(["\x01\x02","\x01\x02","\x01\x02","\x01\x02"], 0, 32, :STRING, 128, @data, :BIG_ENDIAN, :ERROR)
1593
- @data.should eql("\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00")
1593
+ expect(@data).to eql("\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00")
1594
1594
  end
1595
1595
 
1596
- it "should write a shorter string and zero fill to the given bit size" do
1596
+ it "writes a shorter string and zero fill to the given bit size" do
1597
1597
  @data = "\x80\x81\x82\x83\x84\x85\x86\x87\x00\x09\x0A\x0B\x0C\x0D\x0E\x0F"
1598
1598
  BinaryAccessor.write_array(["\x01\x02","\x01\x02","\x01\x02","\x01\x02"], 0, 32, :BLOCK, 128, @data, :BIG_ENDIAN, :ERROR)
1599
- @data.should eql("\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00")
1599
+ expect(@data).to eql("\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00")
1600
1600
  end
1601
1601
 
1602
- it "should complain about unaligned blocks" do
1603
- lambda { BinaryAccessor.write_array(@baseline_data_array[0..1], 7, 16, :BLOCK, 32, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_offset 7 is not byte aligned for data_type BLOCK")
1602
+ it "complains about unaligned blocks" do
1603
+ expect { BinaryAccessor.write_array(@baseline_data_array[0..1], 7, 16, :BLOCK, 32, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 7 is not byte aligned for data_type BLOCK")
1604
1604
  end
1605
1605
 
1606
- it "should complain if write exceeds the size of the buffer" do
1607
- lambda { BinaryAccessor.write_array([], 8, 800, :STRING, 800, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "16 byte buffer insufficient to write STRING at bit_offset 8 with bit_size 800")
1606
+ it "complains if write exceeds the size of the buffer" do
1607
+ expect { BinaryAccessor.write_array([], 8, 800, :STRING, 800, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "16 byte buffer insufficient to write STRING at bit_offset 8 with bit_size 800")
1608
1608
  end
1609
1609
 
1610
- it "should write aligned 8-bit unsigned integers" do
1610
+ it "writes aligned 8-bit unsigned integers" do
1611
1611
  data = @data.clone
1612
1612
  BinaryAccessor.write_array([0,1,2,3,4,5,255,255], 0, 8, :UINT, 0, @data, :BIG_ENDIAN, :ERROR)
1613
- @data.should eql("\x00\x01\x02\x03\x04\x05\xFF\xFF")
1613
+ expect(@data).to eql("\x00\x01\x02\x03\x04\x05\xFF\xFF")
1614
1614
  end
1615
1615
 
1616
- it "should write aligned 8-bit signed integers" do
1616
+ it "writes aligned 8-bit signed integers" do
1617
1617
  data = @data.clone
1618
1618
  BinaryAccessor.write_array([0,1,2,3,4,5,-1,127], 0, 8, :INT, 0, @data, :BIG_ENDIAN, :ERROR)
1619
- @data.should eql("\x00\x01\x02\x03\x04\x05\xFF\x7F")
1619
+ expect(@data).to eql("\x00\x01\x02\x03\x04\x05\xFF\x7F")
1620
1620
  end
1621
1621
 
1622
- it "should complain about unaligned strings" do
1622
+ it "complains about unaligned strings" do
1623
1623
  expect { BinaryAccessor.write_array(['X'], 1, 32, :STRING, 32, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type STRING")
1624
1624
  end
1625
1625
 
1626
- it "should write STRING items" do
1626
+ it "writes STRING items" do
1627
1627
  data = @baseline_data.clone
1628
1628
  BinaryAccessor.write_array(['a'], 0, 64, :STRING, 0, @baseline_data, :BIG_ENDIAN, :ERROR)
1629
- @baseline_data.should eql("a\x00\x00\x00\x00\x00\x00\x00")
1629
+ expect(@baseline_data).to eql("a\x00\x00\x00\x00\x00\x00\x00")
1630
1630
  end
1631
1631
 
1632
- it "should write BLOCK items" do
1632
+ it "writes BLOCK items" do
1633
1633
  BinaryAccessor.write_array(["\x01","\x02","\x03","\x04"], 0, 32, :BLOCK, 0, @baseline_data, :BIG_ENDIAN, :ERROR)
1634
- @baseline_data.should eql("\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00")
1634
+ expect(@baseline_data).to eql("\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00")
1635
1635
  end
1636
1636
 
1637
- it "should write variable length arrays with a zero and negative array_size" do
1637
+ it "writes variable length arrays with a zero and negative array_size" do
1638
1638
  baseline_data_array_uint8 = []
1639
1639
  @baseline_data.length.times {|i| baseline_data_array_uint8 << @baseline_data[i].ord }
1640
1640
  0.step(-(@baseline_data.length * 8), -8) do |array_size|
1641
1641
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1642
1642
  @expected_data = @baseline_data.clone + ("\x00" * -(array_size / 8))
1643
1643
  BinaryAccessor.write_array(baseline_data_array_uint8, 0, 8, :UINT, array_size, @data, :BIG_ENDIAN, :ERROR)
1644
- @data.should eql(@expected_data)
1644
+ expect(@data).to eql(@expected_data)
1645
1645
  end
1646
1646
  end
1647
1647
 
1648
- it "should write variable length arrays or 32-bit UINTS with a zero and negative array_size" do
1648
+ it "writes variable length arrays or 32-bit UINTS with a zero and negative array_size" do
1649
1649
  baseline_data = "\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03\x03\x04\x04\x04\x04"
1650
1650
  data_array_uint32 = [0x01010101, 0x02020202, 0x03030303, 0x04040404]
1651
1651
  0.step(-(baseline_data.length * 8), -8) do |array_size|
1652
1652
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1653
1653
  @expected_data = baseline_data.clone + ("\x00" * -(array_size / 8))
1654
1654
  BinaryAccessor.write_array(data_array_uint32, 0, 32, :UINT, array_size, @data, :BIG_ENDIAN, :ERROR)
1655
- @data.should eql(@expected_data)
1655
+ expect(@data).to eql(@expected_data)
1656
1656
  end
1657
1657
  end
1658
1658
 
1659
- it "should write variable length arrays of 32-bit UINTS with a zero and negative array_size and non-zero bit offset" do
1659
+ it "writes variable length arrays of 32-bit UINTS with a zero and negative array_size and non-zero bit offset" do
1660
1660
  baseline_data = "\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03\x03\x04\x04\x04\x04"
1661
1661
  data_array_uint32 = [0x01010101, 0x02020202, 0x03030303, 0x04040404]
1662
1662
  0.step(-(baseline_data.length * 8), -8) do |array_size|
1663
1663
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1664
1664
  @expected_data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + baseline_data.clone + ("\x00" * -(array_size / 8))
1665
1665
  BinaryAccessor.write_array(data_array_uint32, 128, 32, :UINT, array_size, @data, :BIG_ENDIAN, :ERROR)
1666
- @data.should eql(@expected_data)
1666
+ expect(@data).to eql(@expected_data)
1667
1667
  end
1668
1668
  end
1669
1669
 
1670
- it "should write variable length arrays of 32-bit UINTS with a zero and negative array_size and non-zero bit offset and grow the buffer" do
1670
+ it "writes variable length arrays of 32-bit UINTS with a zero and negative array_size and non-zero bit offset and grow the buffer" do
1671
1671
  baseline_data = "\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03\x03\x04\x04\x04\x04"
1672
1672
  data_array_uint32 = [0x01010101, 0x02020202, 0x03030303, 0x04040404]
1673
1673
  0.step(-(baseline_data.length * 8), -8) do |array_size|
1674
1674
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1675
1675
  @expected_data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + baseline_data.clone + ("\x00" * -(array_size / 8))
1676
1676
  BinaryAccessor.write_array(data_array_uint32, 128, 32, :UINT, array_size, @data, :BIG_ENDIAN, :ERROR)
1677
- @data.should eql(@expected_data)
1677
+ expect(@data).to eql(@expected_data)
1678
1678
  end
1679
1679
  end
1680
1680
 
1681
1681
  describe "given big endian data" do
1682
1682
 
1683
- it "should write 1-bit unsigned integers" do
1683
+ it "writes 1-bit unsigned integers" do
1684
1684
  BinaryAccessor.write_array([1,0,1], 8, 1, :UINT, 3, @data, :BIG_ENDIAN, :ERROR)
1685
- @data.should eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1685
+ expect(@data).to eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1686
1686
  end
1687
1687
 
1688
- it "should write 1-bit signed integers" do
1688
+ it "writes 1-bit signed integers" do
1689
1689
  BinaryAccessor.write_array([1,0,1], 8, 1, :INT, 0, @data, :BIG_ENDIAN, :ERROR)
1690
- @data.should eql("\x00\xA0")
1690
+ expect(@data).to eql("\x00\xA0")
1691
1691
  end
1692
1692
 
1693
- it "should write 7-bit unsigned integers" do
1693
+ it "writes 7-bit unsigned integers" do
1694
1694
  BinaryAccessor.write_array([0x40,0x60,0x50], 8, 7, :UINT, 21, @data, :BIG_ENDIAN, :ERROR)
1695
- @data.should eql("\x00\x81\x82\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1695
+ expect(@data).to eql("\x00\x81\x82\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1696
1696
  end
1697
1697
 
1698
- it "should write aligned 16-bit unsigned integers" do
1698
+ it "writes aligned 16-bit unsigned integers" do
1699
1699
  data = [0x8081, 0x8283, 0x8485, 0x8687, 0x0009, 0x0A0B, 0x0C0D, 0x0E0F]
1700
1700
  BinaryAccessor.write_array(data, 0, 16, :UINT, 0, @data, :BIG_ENDIAN, :ERROR)
1701
- @data.should eql(@baseline_data)
1701
+ expect(@data).to eql(@baseline_data)
1702
1702
  end
1703
1703
 
1704
- it "should write aligned 16-bit signed integers" do
1704
+ it "writes aligned 16-bit signed integers" do
1705
1705
  data = [0x8081, 0x8283, 0x8485, 0x8687, 0x0009, 0x0A0B, 0x0C0D, 0x0E0F]
1706
1706
  data.map! {|x| (x & ~(1 << 15)) - (x & (1 << 15)) } # convert to negative
1707
1707
  BinaryAccessor.write_array(data, 0, 16, :INT, 0, @data, :BIG_ENDIAN, :ERROR)
1708
- @data.should eql(@baseline_data)
1708
+ expect(@data).to eql(@baseline_data)
1709
1709
  end
1710
1710
 
1711
- it "should write aligned 32-bit unsigned integers" do
1711
+ it "writes aligned 32-bit unsigned integers" do
1712
1712
  data = [0x80818283, 0x84858687, 0x00090A0B, 0x0C0D0E0F]
1713
1713
  BinaryAccessor.write_array(data, 0, 32, :UINT, 0, @data, :BIG_ENDIAN, :ERROR)
1714
- @data.should eql(@baseline_data)
1714
+ expect(@data).to eql(@baseline_data)
1715
1715
  end
1716
1716
 
1717
- it "should write aligned 32-bit signed integers" do
1717
+ it "writes aligned 32-bit signed integers" do
1718
1718
  data = [0x80818283, 0x84858687, 0x00090A0B, 0x0C0D0E0F]
1719
1719
  data.map! {|x| (x & ~(1 << 31)) - (x & (1 << 31)) } # convert to negative
1720
1720
  BinaryAccessor.write_array(data, 0, 32, :INT, 0, @data, :BIG_ENDIAN, :ERROR)
1721
- @data.should eql(@baseline_data)
1721
+ expect(@data).to eql(@baseline_data)
1722
1722
  end
1723
1723
 
1724
- it "should write aligned 32-bit floats" do
1724
+ it "writes aligned 32-bit floats" do
1725
1725
  data = [-1.189360e-038, -3.139169e-036, 8.301067e-040, 1.086646e-031]
1726
1726
  BinaryAccessor.write_array(data, 0, 32, :FLOAT, 0, @data, :BIG_ENDIAN, :ERROR)
1727
- BinaryAccessor.read(0, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-038).of(data[0])
1728
- BinaryAccessor.read(32, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-036).of(data[1])
1729
- BinaryAccessor.read(64, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-040).of(data[2])
1730
- BinaryAccessor.read(96, 32, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-031).of(data[3])
1727
+ expect(BinaryAccessor.read(0, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-038).of(data[0])
1728
+ expect(BinaryAccessor.read(32, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-036).of(data[1])
1729
+ expect(BinaryAccessor.read(64, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-040).of(data[2])
1730
+ expect(BinaryAccessor.read(96, 32, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-031).of(data[3])
1731
1731
  end
1732
1732
 
1733
- it "should write aligned 64-bit unsigned integers" do
1733
+ it "writes aligned 64-bit unsigned integers" do
1734
1734
  data = [0x8081828384858687, 0x00090A0B0C0D0E0F]
1735
1735
  BinaryAccessor.write_array(data, 0, 64, :UINT, 0, @data, :BIG_ENDIAN, :ERROR)
1736
- @data.should eql(@baseline_data)
1736
+ expect(@data).to eql(@baseline_data)
1737
1737
  end
1738
1738
 
1739
- it "should write aligned 64-bit signed integers" do
1739
+ it "writes aligned 64-bit signed integers" do
1740
1740
  data = [0x8081828384858687, 0x00090A0B0C0D0E0F]
1741
1741
  data.map! {|x| (x & ~(1 << 63)) - (x & (1 << 63)) } # convert to negative
1742
1742
  BinaryAccessor.write_array(data, 0, 64, :INT, 0, @data, :BIG_ENDIAN, :ERROR)
1743
- @data.should eql(@baseline_data)
1743
+ expect(@data).to eql(@baseline_data)
1744
1744
  end
1745
1745
 
1746
- it "should write aligned 64-bit floats" do
1746
+ it "writes aligned 64-bit floats" do
1747
1747
  data = [-3.116851e-306, 1.257060e-308]
1748
1748
  BinaryAccessor.write_array(data, 0, 64, :FLOAT, 0, @data, :BIG_ENDIAN, :ERROR)
1749
- BinaryAccessor.read(0, 64, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-306).of(data[0])
1750
- BinaryAccessor.read(64, 64, :FLOAT, @data, :BIG_ENDIAN).should be_within(1.0e-308).of(data[1])
1749
+ expect(BinaryAccessor.read(0, 64, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-306).of(data[0])
1750
+ expect(BinaryAccessor.read(64, 64, :FLOAT, @data, :BIG_ENDIAN)).to be_within(1.0e-308).of(data[1])
1751
1751
  end
1752
1752
 
1753
- it "should complain about unaligned floats" do
1754
- lambda { BinaryAccessor.write_array([0.0], 17, 32, :FLOAT, 32, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_offset 17 is not byte aligned for data_type FLOAT")
1753
+ it "complains about unaligned floats" do
1754
+ expect { BinaryAccessor.write_array([0.0], 17, 32, :FLOAT, 32, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 17 is not byte aligned for data_type FLOAT")
1755
1755
  end
1756
1756
 
1757
- it "should complain about mis-sized floats" do
1758
- lambda { BinaryAccessor.write_array([0.0], 0, 33, :FLOAT, 33, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_size is 33 but must be 32 or 64 for data_type FLOAT")
1757
+ it "complains about mis-sized floats" do
1758
+ expect { BinaryAccessor.write_array([0.0], 0, 33, :FLOAT, 33, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size is 33 but must be 32 or 64 for data_type FLOAT")
1759
1759
  end
1760
1760
 
1761
1761
  end # given big endian data
1762
1762
 
1763
1763
  describe "given little endian data" do
1764
1764
 
1765
- it "should write 1-bit unsigned integers" do
1765
+ it "writes 1-bit unsigned integers" do
1766
1766
  BinaryAccessor.write_array([1,0,1], 8, 1, :UINT, 3, @data, :LITTLE_ENDIAN, :ERROR)
1767
- @data.should eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1767
+ expect(@data).to eql("\x00\xA0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
1768
1768
  end
1769
1769
 
1770
- it "should write 1-bit signed integers" do
1770
+ it "writes 1-bit signed integers" do
1771
1771
  BinaryAccessor.write_array([1,0,1], 8, 1, :INT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1772
- @data.should eql("\x00\xA0")
1772
+ expect(@data).to eql("\x00\xA0")
1773
1773
  end
1774
1774
 
1775
- it "should complain about little endian bit-fields greater than 1-bit" do
1775
+ it "complains about little endian bit-fields greater than 1-bit" do
1776
1776
  expect { BinaryAccessor.write_array([0x40,0x60,0x50], 8, 7, :UINT, 21, @data, :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "write_array does not support little endian bit fields with bit_size greater than 1-bit")
1777
1777
  end
1778
1778
 
1779
- it "should write aligned 16-bit unsigned integers" do
1779
+ it "writes aligned 16-bit unsigned integers" do
1780
1780
  data = [0x8180, 0x8382, 0x8584, 0x8786, 0x0900, 0x0B0A, 0x0D0C, 0x0F0E]
1781
1781
  BinaryAccessor.write_array(data, 0, 16, :UINT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1782
- @data.should eql(@baseline_data)
1782
+ expect(@data).to eql(@baseline_data)
1783
1783
  end
1784
1784
 
1785
- it "should write aligned 16-bit signed integers" do
1785
+ it "writes aligned 16-bit signed integers" do
1786
1786
  data = [0x8180, 0x8382, 0x8584, 0x8786, 0x0900, 0x0B0A, 0x0D0C, 0x0F0E]
1787
1787
  data.map! {|x| (x & ~(1 << 15)) - (x & (1 << 15)) } # convert to negative
1788
1788
  BinaryAccessor.write_array(data, 0, 16, :INT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1789
- @data.should eql(@baseline_data)
1789
+ expect(@data).to eql(@baseline_data)
1790
1790
  end
1791
1791
 
1792
- it "should write aligned 32-bit unsigned integers" do
1792
+ it "writes aligned 32-bit unsigned integers" do
1793
1793
  data = [0x83828180, 0x87868584, 0x0B0A0900, 0x0F0E0D0C]
1794
1794
  BinaryAccessor.write_array(data, 0, 32, :UINT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1795
- @data.should eql(@baseline_data)
1795
+ expect(@data).to eql(@baseline_data)
1796
1796
  end
1797
1797
 
1798
- it "should write aligned 32-bit signed integers" do
1798
+ it "writes aligned 32-bit signed integers" do
1799
1799
  data= [0x83828180, 0x87868584, 0x0B0A0900, 0x0F0E0D0C]
1800
1800
  data.map! {|x| (x & ~(1 << 31)) - (x & (1 << 31)) } # convert to negative
1801
1801
  BinaryAccessor.write_array(data, 0, 32, :INT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1802
- @data.should eql(@baseline_data)
1802
+ expect(@data).to eql(@baseline_data)
1803
1803
  end
1804
1804
 
1805
- it "should write aligned 32-bit floats" do
1805
+ it "writes aligned 32-bit floats" do
1806
1806
  data = [-7.670445e-037, -2.024055e-034, 2.658460e-032, 7.003653e-030]
1807
1807
  BinaryAccessor.write_array(data, 0, 32, :FLOAT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1808
- BinaryAccessor.read(0, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-037).of(data[0])
1809
- BinaryAccessor.read(32, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-034).of(data[1])
1810
- BinaryAccessor.read(64, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-032).of(data[2])
1811
- BinaryAccessor.read(96, 32, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-030).of(data[3])
1808
+ expect(BinaryAccessor.read(0, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-037).of(data[0])
1809
+ expect(BinaryAccessor.read(32, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-034).of(data[1])
1810
+ expect(BinaryAccessor.read(64, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-032).of(data[2])
1811
+ expect(BinaryAccessor.read(96, 32, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-030).of(data[3])
1812
1812
  end
1813
1813
 
1814
- it "should write aligned 64-bit unsigned integers" do
1814
+ it "writes aligned 64-bit unsigned integers" do
1815
1815
  data = [0x8786858483828180, 0x0F0E0D0C0B0A0900]
1816
1816
  BinaryAccessor.write_array(data, 0, 64, :UINT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1817
- @data.should eql(@baseline_data)
1817
+ expect(@data).to eql(@baseline_data)
1818
1818
  end
1819
1819
 
1820
- it "should write aligned 64-bit signed integers" do
1820
+ it "writes aligned 64-bit signed integers" do
1821
1821
  data = [0x8786858483828180, 0x0F0E0D0C0B0A0900]
1822
1822
  data.map! {|x| (x & ~(1 << 63)) - (x & (1 << 63)) } # convert to negative
1823
1823
  BinaryAccessor.write_array(data, 0, 64, :INT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1824
- @data.should eql(@baseline_data)
1824
+ expect(@data).to eql(@baseline_data)
1825
1825
  end
1826
1826
 
1827
- it "should write aligned 64-bit floats" do
1827
+ it "writes aligned 64-bit floats" do
1828
1828
  data = [-2.081577e-272, 3.691916e-236]
1829
1829
  BinaryAccessor.write_array(data, 0, 64, :FLOAT, 0, @data, :LITTLE_ENDIAN, :ERROR)
1830
- BinaryAccessor.read(0, 64, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-272).of(data[0])
1831
- BinaryAccessor.read(64, 64, :FLOAT, @data, :LITTLE_ENDIAN).should be_within(1.0e-236).of(data[1])
1830
+ expect(BinaryAccessor.read(0, 64, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-272).of(data[0])
1831
+ expect(BinaryAccessor.read(64, 64, :FLOAT, @data, :LITTLE_ENDIAN)).to be_within(1.0e-236).of(data[1])
1832
1832
  end
1833
1833
 
1834
- it "should complain about unaligned floats" do
1835
- lambda { BinaryAccessor.write_array([0.0], 1, 32, :FLOAT, 32, @data, :LITTLE_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type FLOAT")
1834
+ it "complains about unaligned floats" do
1835
+ expect { BinaryAccessor.write_array([0.0], 1, 32, :FLOAT, 32, @data, :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_offset 1 is not byte aligned for data_type FLOAT")
1836
1836
  end
1837
1837
 
1838
- it "should complain about mis-sized floats" do
1839
- lambda { BinaryAccessor.write_array([0.0], 0, 65, :FLOAT, 65, @data, :LITTLE_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "bit_size is 65 but must be 32 or 64 for data_type FLOAT")
1838
+ it "complains about mis-sized floats" do
1839
+ expect { BinaryAccessor.write_array([0.0], 0, 65, :FLOAT, 65, @data, :LITTLE_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "bit_size is 65 but must be 32 or 64 for data_type FLOAT")
1840
1840
  end
1841
1841
 
1842
1842
  end # given little endian data
@@ -1846,222 +1846,222 @@ module Cosmos
1846
1846
  @data = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
1847
1847
  end
1848
1848
 
1849
- it "should prevent overflow of STRING" do
1850
- lambda { BinaryAccessor.write_array(["abcde"], 0, 32, :STRING, 32, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of 5 bytes does not fit into 4 bytes for data_type STRING")
1849
+ it "prevents overflow of STRING" do
1850
+ expect { BinaryAccessor.write_array(["abcde"], 0, 32, :STRING, 32, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of 5 bytes does not fit into 4 bytes for data_type STRING")
1851
1851
  end
1852
1852
 
1853
- it "should prevent overflow of BLOCK" do
1854
- lambda { BinaryAccessor.write_array(["abcde"], 0, 32, :BLOCK, 32, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of 5 bytes does not fit into 4 bytes for data_type BLOCK")
1853
+ it "prevents overflow of BLOCK" do
1854
+ expect { BinaryAccessor.write_array(["abcde"], 0, 32, :BLOCK, 32, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of 5 bytes does not fit into 4 bytes for data_type BLOCK")
1855
1855
  end
1856
1856
 
1857
- it "should prevent overflow of 8-bit INT" do
1857
+ it "prevents overflow of 8-bit INT" do
1858
1858
  bit_size = 8; data_type = :INT; value = 2 ** (bit_size - 1)
1859
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1859
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1860
1860
  end
1861
1861
 
1862
- it "should prevent overflow of 16-bit INT" do
1862
+ it "prevents overflow of 16-bit INT" do
1863
1863
  bit_size = 16; data_type = :INT; value = 2 ** (bit_size - 1)
1864
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1864
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1865
1865
  end
1866
1866
 
1867
- it "should prevent overflow of 32-bit INT" do
1867
+ it "prevents overflow of 32-bit INT" do
1868
1868
  bit_size = 32; data_type = :INT; value = 2 ** (bit_size - 1)
1869
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1869
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1870
1870
  end
1871
1871
 
1872
- it "should prevent overflow of 64-bit INT" do
1872
+ it "prevents overflow of 64-bit INT" do
1873
1873
  bit_size = 64; data_type = :INT; value = 2 ** (bit_size - 1)
1874
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1874
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1875
1875
  end
1876
1876
 
1877
- it "should prevent overflow of 3-bit INT" do
1877
+ it "prevents overflow of 3-bit INT" do
1878
1878
  bit_size = 3; data_type = :INT; value = 2 ** (bit_size - 1)
1879
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1879
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1880
1880
  end
1881
1881
 
1882
- it "should prevent overflow of 8-bit UINT" do
1882
+ it "prevents overflow of 8-bit UINT" do
1883
1883
  bit_size = 8; data_type = :UINT; value = 2 ** bit_size
1884
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1884
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1885
1885
  end
1886
1886
 
1887
- it "should prevent overflow of 16-bit UINT" do
1887
+ it "prevents overflow of 16-bit UINT" do
1888
1888
  bit_size = 16; data_type = :UINT; value = 2 ** bit_size
1889
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1889
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1890
1890
  end
1891
1891
 
1892
- it "should prevent overflow of 32-bit UINT" do
1892
+ it "prevents overflow of 32-bit UINT" do
1893
1893
  bit_size = 32; data_type = :UINT; value = 2 ** bit_size
1894
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1894
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1895
1895
  end
1896
1896
 
1897
- it "should prevent overflow of 64-bit UINT" do
1897
+ it "prevents overflow of 64-bit UINT" do
1898
1898
  bit_size = 64; data_type = :UINT; value = 2 ** bit_size
1899
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1899
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1900
1900
  end
1901
1901
 
1902
- it "should prevent overflow of 3-bit UINT" do
1902
+ it "prevents overflow of 3-bit UINT" do
1903
1903
  bit_size = 3; data_type = :UINT; value = 2 ** bit_size
1904
- lambda { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.should raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1904
+ expect { BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR) }.to raise_error(ArgumentError, "value of #{value} invalid for #{bit_size}-bit #{data_type}")
1905
1905
  end
1906
1906
 
1907
- it "should truncate STRING" do
1907
+ it "truncates STRING" do
1908
1908
  BinaryAccessor.write_array(["abcde"], 0, 32, :STRING, 32, @data, :BIG_ENDIAN, :TRUNCATE)
1909
- @data[0..4].should eql "abcd\x00"
1909
+ expect(@data[0..4]).to eql "abcd\x00"
1910
1910
  end
1911
1911
 
1912
- it "should truncate BLOCK" do
1912
+ it "truncates BLOCK" do
1913
1913
  BinaryAccessor.write_array(["abcde"], 0, 32, :BLOCK, 32, @data, :BIG_ENDIAN, :TRUNCATE)
1914
- @data[0..4].should eql "abcd\x00"
1914
+ expect(@data[0..4]).to eql "abcd\x00"
1915
1915
  end
1916
1916
 
1917
- it "should truncate 8-bit INT" do
1917
+ it "truncates 8-bit INT" do
1918
1918
  bit_size = 8; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1919
1919
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1920
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1920
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1921
1921
  end
1922
1922
 
1923
- it "should truncate 16-bit INT" do
1923
+ it "truncates 16-bit INT" do
1924
1924
  bit_size = 16; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1925
1925
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1926
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1926
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1927
1927
  end
1928
1928
 
1929
- it "should truncate 32-bit INT" do
1929
+ it "truncates 32-bit INT" do
1930
1930
  bit_size = 32; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1931
1931
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1932
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1932
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1933
1933
  end
1934
1934
 
1935
- it "should truncate 64-bit INT" do
1935
+ it "truncates 64-bit INT" do
1936
1936
  bit_size = 64; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1937
1937
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1938
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1938
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1939
1939
  end
1940
1940
 
1941
- it "should truncate 3-bit INT" do
1941
+ it "truncates 3-bit INT" do
1942
1942
  bit_size = 3; data_type = :INT; value = 2 ** (bit_size - 1); truncated_value = -value
1943
1943
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1944
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1944
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1945
1945
  end
1946
1946
 
1947
- it "should truncate 8-bit UINT" do
1947
+ it "truncates 8-bit UINT" do
1948
1948
  bit_size = 8; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1949
1949
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1950
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1950
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1951
1951
  end
1952
1952
 
1953
- it "should truncate 16-bit UINT" do
1953
+ it "truncates 16-bit UINT" do
1954
1954
  bit_size = 16; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1955
1955
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1956
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1956
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1957
1957
  end
1958
1958
 
1959
- it "should truncate 32-bit UINT" do
1959
+ it "truncates 32-bit UINT" do
1960
1960
  bit_size = 32; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1961
1961
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1962
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1962
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1963
1963
  end
1964
1964
 
1965
- it "should truncate 64-bit UINT" do
1965
+ it "truncates 64-bit UINT" do
1966
1966
  bit_size = 64; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1967
1967
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1968
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1968
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1969
1969
  end
1970
1970
 
1971
- it "should truncate 3-bit UINT" do
1971
+ it "truncates 3-bit UINT" do
1972
1972
  bit_size = 3; data_type = :UINT; value = 2 ** bit_size + 1; truncated_value = 1
1973
1973
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :TRUNCATE)
1974
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql truncated_value
1974
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql truncated_value
1975
1975
  end
1976
1976
 
1977
- it "should saturate 8-bit INT" do
1977
+ it "saturates 8-bit INT" do
1978
1978
  bit_size = 8; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1979
1979
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
1980
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1980
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1981
1981
  end
1982
1982
 
1983
- it "should saturate 16-bit INT" do
1983
+ it "saturates 16-bit INT" do
1984
1984
  bit_size = 16; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1985
1985
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
1986
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1986
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1987
1987
  end
1988
1988
 
1989
- it "should saturate 32-bit INT" do
1989
+ it "saturates 32-bit INT" do
1990
1990
  bit_size = 32; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1991
1991
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
1992
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1992
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1993
1993
  end
1994
1994
 
1995
- it "should saturate 64-bit INT" do
1995
+ it "saturates 64-bit INT" do
1996
1996
  bit_size = 64; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
1997
1997
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
1998
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
1998
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
1999
1999
  end
2000
2000
 
2001
- it "should saturate 3-bit INT" do
2001
+ it "saturates 3-bit INT" do
2002
2002
  bit_size = 3; data_type = :INT; value = 2 ** (bit_size - 1); saturated_value = value - 1
2003
2003
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
2004
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
2004
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
2005
2005
  end
2006
2006
 
2007
- it "should saturate 8-bit UINT" do
2007
+ it "saturates 8-bit UINT" do
2008
2008
  bit_size = 8; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
2009
2009
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
2010
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
2010
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
2011
2011
  end
2012
2012
 
2013
- it "should saturate 16-bit UINT" do
2013
+ it "saturates 16-bit UINT" do
2014
2014
  bit_size = 16; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
2015
2015
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
2016
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
2016
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
2017
2017
  end
2018
2018
 
2019
- it "should saturate 32-bit UINT" do
2019
+ it "saturates 32-bit UINT" do
2020
2020
  bit_size = 32; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
2021
2021
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
2022
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
2022
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
2023
2023
  end
2024
2024
 
2025
- it "should saturate 64-bit UINT" do
2025
+ it "saturates 64-bit UINT" do
2026
2026
  bit_size = 64; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
2027
2027
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
2028
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
2028
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
2029
2029
  end
2030
2030
 
2031
- it "should saturate 3-bit UINT" do
2031
+ it "saturates 3-bit UINT" do
2032
2032
  bit_size = 3; data_type = :UINT; value = 2 ** bit_size; saturated_value = value - 1
2033
2033
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :SATURATE)
2034
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql saturated_value
2034
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql saturated_value
2035
2035
  end
2036
2036
 
2037
- it "should allow hex value entry of 8-bit INT" do
2037
+ it "allows hex value entry of 8-bit INT" do
2038
2038
  bit_size = 8; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
2039
2039
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
2040
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
2040
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
2041
2041
  end
2042
2042
 
2043
- it "should allow hex value entry of 16-bit INT" do
2043
+ it "allows hex value entry of 16-bit INT" do
2044
2044
  bit_size = 16; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
2045
2045
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
2046
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
2046
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
2047
2047
  end
2048
2048
 
2049
- it "should allow hex value entry of 32-bit INT" do
2049
+ it "allows hex value entry of 32-bit INT" do
2050
2050
  bit_size = 32; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
2051
2051
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
2052
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
2052
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
2053
2053
  end
2054
2054
 
2055
- it "should allow hex value entry of 64-bit INT" do
2055
+ it "allows hex value entry of 64-bit INT" do
2056
2056
  bit_size = 64; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
2057
2057
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
2058
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
2058
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
2059
2059
  end
2060
2060
 
2061
- it "should allow hex value entry of 3-bit INT" do
2061
+ it "allows hex value entry of 3-bit INT" do
2062
2062
  bit_size = 3; data_type = :INT; value = 2 ** bit_size - 1; allowed_value = -1
2063
2063
  BinaryAccessor.write_array([value], 0, bit_size, data_type, bit_size, @data, :BIG_ENDIAN, :ERROR_ALLOW_HEX)
2064
- BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN).should eql allowed_value
2064
+ expect(BinaryAccessor.read(0, bit_size, data_type, @data, :BIG_ENDIAN)).to eql allowed_value
2065
2065
  end
2066
2066
 
2067
2067
  end