cosmos 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +195 -0
- data/README.md +3 -3
- data/data/crc.txt +52 -52
- data/lib/cosmos.rb +1 -1
- data/lib/cosmos/core_ext/time.rb +11 -9
- data/lib/cosmos/gui/choosers/telemetry_chooser.rb +0 -2
- data/lib/cosmos/gui/dialogs/about_dialog.rb +2 -2
- data/lib/cosmos/gui/dialogs/exception_dialog.rb +2 -2
- data/lib/cosmos/gui/dialogs/progress_dialog.rb +11 -5
- data/lib/cosmos/gui/dialogs/splash.rb +32 -10
- data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +1 -1
- data/lib/cosmos/gui/line_graph/line_graph_drawing.rb +2 -2
- data/lib/cosmos/gui/qt.rb +22 -22
- data/lib/cosmos/io/json_drb.rb +4 -4
- data/lib/cosmos/io/json_rpc.rb +21 -21
- data/lib/cosmos/packet_logs/packet_log_writer.rb +18 -20
- data/lib/cosmos/packets/commands.rb +8 -6
- data/lib/cosmos/packets/limits.rb +3 -2
- data/lib/cosmos/packets/packet.rb +14 -11
- data/lib/cosmos/packets/parsers/limits_parser.rb +1 -1
- data/lib/cosmos/packets/parsers/macro_parser.rb +4 -4
- data/lib/cosmos/packets/parsers/state_parser.rb +1 -1
- data/lib/cosmos/packets/structure.rb +2 -2
- data/lib/cosmos/packets/telemetry.rb +5 -4
- data/lib/cosmos/script/script.rb +6 -6
- data/lib/cosmos/streams/tcpip_socket_stream.rb +2 -1
- data/lib/cosmos/streams/template_stream_protocol.rb +1 -1
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +5 -8
- data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +4 -3
- data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +9 -3
- data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +15 -11
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +1 -1
- data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +2 -2
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +2 -2
- data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +0 -2
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +1 -1
- data/lib/cosmos/tools/replay/replay.rb +2 -2
- data/lib/cosmos/tools/script_runner/script_audit.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +3 -7
- data/lib/cosmos/tools/table_manager/table_config.rb +1 -1
- data/lib/cosmos/tools/test_runner/results_writer.rb +1 -1
- data/lib/cosmos/tools/test_runner/test_runner.rb +2 -2
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +2 -1
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +1 -1
- data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +1 -0
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +1 -0
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/xy_data_object_editor.rb +1 -0
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb +3 -3
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +1 -3
- data/lib/cosmos/top_level.rb +2 -6
- data/lib/cosmos/utilities/ruby_lex_utils.rb +1 -1
- data/lib/cosmos/version.rb +5 -5
- data/lib/cosmos/win32/win32_main.rb +11 -7
- data/spec/ccsds/ccsds_packet_spec.rb +28 -28
- data/spec/ccsds/ccsds_parser_spec.rb +27 -27
- data/spec/config/config_parser_spec.rb +88 -88
- data/spec/conversions/conversion_spec.rb +3 -3
- data/spec/conversions/generic_conversion_spec.rb +9 -9
- data/spec/conversions/new_packet_log_conversion_spec.rb +4 -4
- data/spec/conversions/polynomial_conversion_spec.rb +7 -7
- data/spec/conversions/processor_conversion_spec.rb +9 -9
- data/spec/conversions/received_count_conversion_spec.rb +7 -7
- data/spec/conversions/received_time_formatted_conversion_spec.rb +9 -9
- data/spec/conversions/received_time_seconds_conversion_spec.rb +9 -9
- data/spec/conversions/segmented_polynomial_conversion_spec.rb +11 -11
- data/spec/conversions/unix_time_formatted_conversion_spec.rb +13 -13
- data/spec/conversions/unix_time_seconds_conversion_spec.rb +13 -13
- data/spec/core_ext/array_spec.rb +76 -76
- data/spec/core_ext/class_spec.rb +3 -3
- data/spec/core_ext/cosmos_io_spec.rb +16 -16
- data/spec/core_ext/exception_spec.rb +19 -19
- data/spec/core_ext/file_spec.rb +16 -16
- data/spec/core_ext/hash_spec.rb +3 -3
- data/spec/core_ext/io_spec.rb +2 -2
- data/spec/core_ext/kernel_spec.rb +2 -2
- data/spec/core_ext/math_spec.rb +43 -43
- data/spec/core_ext/matrix_spec.rb +22 -22
- data/spec/core_ext/objectspace_spec.rb +6 -6
- data/spec/core_ext/range_spec.rb +2 -2
- data/spec/core_ext/socket_spec.rb +4 -4
- data/spec/core_ext/string_spec.rb +67 -67
- data/spec/core_ext/stringio_spec.rb +2 -2
- data/spec/core_ext/time_spec.rb +82 -82
- data/spec/gui/line_graph/line_clip_spec.rb +34 -34
- data/spec/interfaces/interface_spec.rb +46 -46
- data/spec/interfaces/linc_interface_spec.rb +26 -26
- data/spec/interfaces/serial_interface_spec.rb +16 -16
- data/spec/interfaces/simulated_target_interface_spec.rb +21 -21
- data/spec/interfaces/stream_interface_spec.rb +22 -22
- data/spec/interfaces/tcpip_client_interface_spec.rb +14 -14
- data/spec/interfaces/tcpip_server_interface_spec.rb +41 -41
- data/spec/interfaces/udp_interface_spec.rb +46 -46
- data/spec/io/buffered_file_spec.rb +50 -50
- data/spec/io/io_multiplexer_spec.rb +9 -9
- data/spec/io/json_drb_object_spec.rb +7 -7
- data/spec/io/json_drb_spec.rb +55 -55
- data/spec/io/json_rpc_spec.rb +68 -68
- data/spec/io/raw_logger_pair_spec.rb +28 -28
- data/spec/io/raw_logger_spec.rb +22 -22
- data/spec/io/serial_driver_spec.rb +3 -3
- data/spec/io/stderr_spec.rb +2 -2
- data/spec/io/stdout_spec.rb +2 -2
- data/spec/io/tcpip_server_spec.rb +62 -62
- data/spec/io/udp_sockets_spec.rb +19 -19
- data/spec/io/win32_serial_driver_spec.rb +10 -10
- data/spec/packet_logs/meta_packet_log_writer_spec.rb +32 -32
- data/spec/packet_logs/packet_log_reader_spec.rb +138 -138
- data/spec/packet_logs/packet_log_writer_pair_spec.rb +3 -3
- data/spec/packet_logs/packet_log_writer_spec.rb +26 -26
- data/spec/packets/binary_accessor_spec.rb +672 -672
- data/spec/packets/commands_spec.rb +123 -123
- data/spec/packets/limits_response_spec.rb +1 -1
- data/spec/packets/limits_spec.rb +69 -69
- data/spec/packets/packet_config_spec.rb +93 -93
- data/spec/packets/packet_item_limits_spec.rb +46 -46
- data/spec/packets/packet_item_spec.rb +108 -108
- data/spec/packets/packet_spec.rb +364 -348
- data/spec/packets/parsers/format_string_parser_spec.rb +13 -13
- data/spec/packets/parsers/limits_parser_spec.rb +8 -8
- data/spec/packets/parsers/limits_response_parser_spec.rb +9 -9
- data/spec/packets/parsers/macro_parser_spec.rb +34 -6
- data/spec/packets/parsers/packet_parser_spec.rb +6 -6
- data/spec/packets/parsers/processor_parser_spec.rb +7 -7
- data/spec/packets/parsers/state_parser_spec.rb +23 -23
- data/spec/packets/structure_item_spec.rb +62 -62
- data/spec/packets/structure_spec.rb +183 -183
- data/spec/packets/telemetry_spec.rb +174 -174
- data/spec/processors/new_packet_log_processor_spec.rb +4 -4
- data/spec/processors/processor_spec.rb +9 -9
- data/spec/processors/statistics_processor_spec.rb +21 -21
- data/spec/processors/watermark_processor_spec.rb +12 -12
- data/spec/script/script_spec.rb +158 -158
- data/spec/spec_helper.rb +44 -13
- data/spec/streams/burst_stream_protocol_spec.rb +8 -8
- data/spec/streams/fixed_stream_protocol_spec.rb +26 -26
- data/spec/streams/length_stream_protocol_spec.rb +27 -27
- data/spec/streams/preidentified_stream_protocol_spec.rb +25 -25
- data/spec/streams/serial_stream_spec.rb +19 -19
- data/spec/streams/stream_protocol_spec.rb +52 -52
- data/spec/streams/stream_spec.rb +1 -1
- data/spec/streams/tcpip_client_stream_spec.rb +7 -7
- data/spec/streams/tcpip_socket_stream_spec.rb +84 -49
- data/spec/streams/template_stream_protocol_spec.rb +17 -17
- data/spec/streams/terminated_stream_protocol_spec.rb +19 -19
- data/spec/system/system_spec.rb +95 -95
- data/spec/system/target_spec.rb +32 -32
- data/spec/tools/cmd_tlm_server/api_spec.rb +386 -386
- data/spec/tools/cmd_tlm_server/background_task_spec.rb +3 -3
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +8 -8
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +57 -57
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +85 -85
- data/spec/tools/cmd_tlm_server/commanding_spec.rb +11 -11
- data/spec/tools/cmd_tlm_server/connections_spec.rb +23 -23
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +57 -57
- data/spec/tools/cmd_tlm_server/interfaces_spec.rb +32 -32
- data/spec/tools/cmd_tlm_server/packet_logging_spec.rb +17 -17
- data/spec/tools/cmd_tlm_server/router_thread_spec.rb +15 -15
- data/spec/tools/cmd_tlm_server/routers_spec.rb +36 -36
- data/spec/top_level/top_level_spec.rb +60 -60
- data/spec/utilities/crc_spec.rb +6 -6
- data/spec/utilities/csv_spec.rb +13 -13
- data/spec/utilities/logger_spec.rb +20 -20
- data/spec/utilities/message_log_spec.rb +13 -13
- data/spec/utilities/quaternion_spec.rb +30 -30
- data/spec/utilities/ruby_lex_utils_spec.rb +14 -14
- data/test/benchmarks/binary_accessor_benchmark.rb +14 -0
- data/test/benchmarks/gsub_benchmark.rb +114 -0
- data/test/performance/PACKETS.bat +1 -0
- data/test/performance/Rakefile +77 -0
- data/test/performance/THREADS.bat +1 -0
- data/test/performance/config/data/attitude.bin +0 -0
- data/test/performance/config/data/crc.txt +206 -0
- data/test/performance/config/data/diamond.STL +58 -0
- data/test/performance/config/data/groundoff.gif +0 -0
- data/test/performance/config/data/groundon.gif +0 -0
- data/test/performance/config/data/hselectoff.gif +0 -0
- data/test/performance/config/data/hselecton.gif +0 -0
- data/test/performance/config/data/hswitchoff.gif +0 -0
- data/test/performance/config/data/hswitchon.gif +0 -0
- data/test/performance/config/data/meta_init.txt +4 -0
- data/test/performance/config/data/position.bin +0 -0
- data/test/performance/config/data/poweroff.gif +0 -0
- data/test/performance/config/data/poweron.gif +0 -0
- data/test/performance/config/data/satellite.gif +0 -0
- data/test/performance/config/data/tada.wav +0 -0
- data/test/performance/config/data/vswitchoff.gif +0 -0
- data/test/performance/config/data/vswitchon.gif +0 -0
- data/test/performance/config/system/system_packets.txt +39 -0
- data/test/performance/config/system/system_threads.txt +59 -0
- data/test/performance/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +41 -0
- data/test/performance/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +15 -0
- data/test/performance/config/targets/COSMOS/cmd_tlm_server.txt +6 -0
- data/test/performance/config/targets/COSMOS/screens/limits_change.txt +20 -0
- data/test/performance/config/targets/COSMOS/screens/version.txt +19 -0
- data/test/performance/config/targets/COSMOS/target.txt +11 -0
- data/test/performance/config/targets/EXAMPLE/cmd_tlm/example_cmds.txt +17 -0
- data/test/performance/config/targets/EXAMPLE/cmd_tlm/example_tlm.txt +18 -0
- data/test/performance/config/targets/EXAMPLE/cmd_tlm_server.txt +6 -0
- data/test/performance/config/targets/EXAMPLE/lib/example_interface.rb +22 -0
- data/test/performance/config/targets/EXAMPLE/target.txt +7 -0
- data/test/performance/config/targets/SYSTEM/screens/status.txt +12 -0
- data/test/performance/config/tools/cmd_tlm_server/cmd_tlm_server_packets.txt +34 -0
- data/test/performance/config/tools/cmd_tlm_server/cmd_tlm_server_threads.txt +68 -0
- data/test/performance/config/tools/data_viewer/data_viewer.txt +11 -0
- data/test/performance/config/tools/handbook_creator/default_toc.xsl +59 -0
- data/test/performance/config/tools/handbook_creator/handbook_creator.txt +66 -0
- data/test/performance/config/tools/handbook_creator/templates/command_packets.html.erb +86 -0
- data/test/performance/config/tools/handbook_creator/templates/command_toc.html.erb +38 -0
- data/test/performance/config/tools/handbook_creator/templates/footer.html.erb +9 -0
- data/test/performance/config/tools/handbook_creator/templates/header.html.erb +25 -0
- data/test/performance/config/tools/handbook_creator/templates/limits_groups.html.erb +13 -0
- data/test/performance/config/tools/handbook_creator/templates/nav.html.erb +27 -0
- data/test/performance/config/tools/handbook_creator/templates/overview.html.erb +1 -0
- data/test/performance/config/tools/handbook_creator/templates/pdf_cover.html.erb +23 -0
- data/test/performance/config/tools/handbook_creator/templates/pdf_footer.html.erb +33 -0
- data/test/performance/config/tools/handbook_creator/templates/pdf_header.html.erb +41 -0
- data/test/performance/config/tools/handbook_creator/templates/telemetry_packets.html.erb +80 -0
- data/test/performance/config/tools/handbook_creator/templates/telemetry_toc.html.erb +38 -0
- data/test/performance/config/tools/handbook_creator/templates/title.html.erb +1 -0
- data/test/performance/config/tools/launcher/launcher_packets.txt +29 -0
- data/test/performance/config/tools/launcher/launcher_threads.txt +70 -0
- data/test/performance/config/tools/limits_monitor/README.txt +1 -0
- data/test/performance/config/tools/opengl_builder/README.txt +1 -0
- data/test/performance/config/tools/script_runner/script_runner.txt +3 -0
- data/test/performance/config/tools/table_manager/ConfigTables_def.txt +8 -0
- data/test/performance/config/tools/table_manager/ExampleTableDefinition.txt +24 -0
- data/test/performance/config/tools/table_manager/MCConfigurationTable_fsw1_def.txt +25 -0
- data/test/performance/config/tools/table_manager/MCConfigurationTable_fsw2_def.txt +25 -0
- data/test/performance/config/tools/table_manager/PPSSelectionTable_def.txt +8 -0
- data/test/performance/config/tools/table_manager/TLMMonitoringTable_def.txt +248 -0
- data/test/performance/config/tools/test_runner/test_runner.txt +17 -0
- data/test/performance/config/tools/tlm_extractor/tlm_extractor.txt +13 -0
- data/test/performance/config/tools/tlm_extractor/tlm_extractor2.txt +2 -0
- data/test/performance/config/tools/tlm_extractor/tlm_extractor3.txt +2 -0
- data/test/performance/config/tools/tlm_extractor/tlm_extractor4.txt +2 -0
- data/test/performance/config/tools/tlm_grapher/README.txt +1 -0
- data/test/performance/config/tools/tlm_viewer/tlm_viewer.txt +41 -0
- data/test/performance/lib/example_background_task.rb +57 -0
- data/test/performance/lib/example_target.rb +120 -0
- data/test/performance/lib/scpi_target.rb +74 -0
- data/test/performance/lib/user_version.rb +3 -0
- data/test/performance/outputs/handbooks/README.txt +1 -0
- data/test/performance/outputs/logs/README.txt +1 -0
- data/test/performance/outputs/saved_config/README.txt +1 -0
- data/test/performance/outputs/tables/README.txt +1 -0
- data/test/performance/outputs/tmp/README.txt +1 -0
- data/test/performance/procedures/checks.rb +11 -0
- data/test/performance/procedures/clear_util.rb +7 -0
- data/test/performance/procedures/collect.rb +18 -0
- data/test/performance/procedures/collect_util.rb +14 -0
- data/test/performance/procedures/cosmos_api_test.rb +293 -0
- data/test/performance/procedures/disconnect.rb +29 -0
- data/test/performance/procedures/example_test.rb +182 -0
- data/test/performance/procedures/plot_test.rb +8 -0
- data/test/performance/procedures/procedure.rb +3 -0
- data/test/performance/procedures/run_example_test.rb +3 -0
- data/test/performance/procedures/test.rb +51 -0
- data/test/performance/tools/CmdExtractor +14 -0
- data/test/performance/tools/CmdExtractor.bat +59 -0
- data/test/performance/tools/CmdSender +14 -0
- data/test/performance/tools/CmdSender.bat +59 -0
- data/test/performance/tools/CmdTlmServer +16 -0
- data/test/performance/tools/CmdTlmServer.bat +59 -0
- data/test/performance/tools/CmdTlmServerMemProf +20 -0
- data/test/performance/tools/CmdTlmServerMemProf.bat +59 -0
- data/test/performance/tools/DataViewer +14 -0
- data/test/performance/tools/DataViewer.bat +59 -0
- data/test/performance/tools/ExampleTarget +14 -0
- data/test/performance/tools/ExampleTarget.bat +59 -0
- data/test/performance/tools/HandbookCreator +14 -0
- data/test/performance/tools/HandbookCreator.bat +61 -0
- data/test/performance/tools/Launcher +14 -0
- data/test/performance/tools/Launcher.bat +59 -0
- data/test/performance/tools/LimitsMonitor +14 -0
- data/test/performance/tools/LimitsMonitor.bat +59 -0
- data/test/performance/tools/OpenGLBuilder +14 -0
- data/test/performance/tools/OpenGLBuilder.bat +59 -0
- data/test/performance/tools/PacketViewer +14 -0
- data/test/performance/tools/PacketViewer.bat +59 -0
- data/test/performance/tools/Replay +14 -0
- data/test/performance/tools/Replay.bat +59 -0
- data/test/performance/tools/ScpiTarget +14 -0
- data/test/performance/tools/ScpiTarget.bat +59 -0
- data/test/performance/tools/ScriptRunner +14 -0
- data/test/performance/tools/ScriptRunner.bat +59 -0
- data/test/performance/tools/TableManager +14 -0
- data/test/performance/tools/TableManager.bat +59 -0
- data/test/performance/tools/TestRunner +14 -0
- data/test/performance/tools/TestRunner.bat +59 -0
- data/test/performance/tools/TlmExtractor +14 -0
- data/test/performance/tools/TlmExtractor.bat +59 -0
- data/test/performance/tools/TlmGrapher +14 -0
- data/test/performance/tools/TlmGrapher.bat +59 -0
- data/test/performance/tools/TlmViewer +14 -0
- data/test/performance/tools/TlmViewer.bat +59 -0
- data/test/performance/tools/mac/CmdExtractor.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/CmdExtractor.app/Contents/MacOS/CmdExtractor.rb +15 -0
- data/test/performance/tools/mac/CmdExtractor.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/CmdExtractor.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/CmdSender.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/CmdSender.app/Contents/MacOS/CmdSender.rb +15 -0
- data/test/performance/tools/mac/CmdSender.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/CmdSender.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/CmdTlmServer.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/CmdTlmServer.app/Contents/MacOS/CmdTlmServer.rb +15 -0
- data/test/performance/tools/mac/CmdTlmServer.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/CmdTlmServer.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/DataViewer.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/DataViewer.app/Contents/MacOS/DataViewer.rb +15 -0
- data/test/performance/tools/mac/DataViewer.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/DataViewer.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/HandbookCreator.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/HandbookCreator.app/Contents/MacOS/HandbookCreator.rb +15 -0
- data/test/performance/tools/mac/HandbookCreator.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/HandbookCreator.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/Launcher.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/Launcher.app/Contents/MacOS/Launcher.rb +15 -0
- data/test/performance/tools/mac/Launcher.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/Launcher.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/LimitsMonitor.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/LimitsMonitor.app/Contents/MacOS/LimitsMonitor.rb +15 -0
- data/test/performance/tools/mac/LimitsMonitor.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/LimitsMonitor.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/OpenGLBuilder.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/OpenGLBuilder.app/Contents/MacOS/OpenGLBuilder.rb +15 -0
- data/test/performance/tools/mac/OpenGLBuilder.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/OpenGLBuilder.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/PacketViewer.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/PacketViewer.app/Contents/MacOS/PacketViewer.rb +15 -0
- data/test/performance/tools/mac/PacketViewer.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/PacketViewer.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/Replay.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/Replay.app/Contents/MacOS/Replay.rb +15 -0
- data/test/performance/tools/mac/Replay.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/Replay.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/ScriptRunner.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/ScriptRunner.app/Contents/MacOS/ScriptRunner.rb +15 -0
- data/test/performance/tools/mac/ScriptRunner.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/ScriptRunner.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TableManager.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TableManager.app/Contents/MacOS/TableManager.rb +15 -0
- data/test/performance/tools/mac/TableManager.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TableManager.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TestRunner.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TestRunner.app/Contents/MacOS/TestRunner.rb +15 -0
- data/test/performance/tools/mac/TestRunner.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TestRunner.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TlmExtractor.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TlmExtractor.app/Contents/MacOS/TlmExtractor.rb +15 -0
- data/test/performance/tools/mac/TlmExtractor.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TlmExtractor.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TlmGrapher.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TlmGrapher.app/Contents/MacOS/TlmGrapher.rb +15 -0
- data/test/performance/tools/mac/TlmGrapher.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TlmGrapher.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/tools/mac/TlmViewer.app/Contents/Info.plist +38 -0
- data/test/performance/tools/mac/TlmViewer.app/Contents/MacOS/TlmViewer.rb +15 -0
- data/test/performance/tools/mac/TlmViewer.app/Contents/MacOS/main.sh +6 -0
- data/test/performance/tools/mac/TlmViewer.app/Contents/Resources/appIcon.icns +0 -0
- data/test/performance/userpath.txt +1 -0
- metadata +197 -2
@@ -17,177 +17,177 @@ module Cosmos
|
|
17
17
|
describe StructureItem do
|
18
18
|
|
19
19
|
describe "name=" do
|
20
|
-
it "
|
21
|
-
StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, nil).name.
|
20
|
+
it "creates new structure items" do
|
21
|
+
expect(StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, nil).name).to eql "TEST"
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "complains about non String names" do
|
25
25
|
expect { StructureItem.new(nil, 0, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "name must be a String but is a NilClass")
|
26
26
|
expect { StructureItem.new(5, 0, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "name must be a String but is a Fixnum")
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "complains about blank names" do
|
30
30
|
expect { StructureItem.new("", 0, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "name must contain at least one character")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "endianness=" do
|
35
|
-
it "
|
36
|
-
StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, nil).endianness.
|
37
|
-
StructureItem.new("test", 0, 8, :UINT, :LITTLE_ENDIAN, nil).endianness.
|
35
|
+
it "accepts BIG_ENDIAN and LITTLE_ENDIAN" do
|
36
|
+
expect(StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, nil).endianness).to eql :BIG_ENDIAN
|
37
|
+
expect(StructureItem.new("test", 0, 8, :UINT, :LITTLE_ENDIAN, nil).endianness).to eql :LITTLE_ENDIAN
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "complains about bad endianness" do
|
41
41
|
expect { StructureItem.new("test", 0, 8, :UINT, :BLAH, nil) }.to raise_error(ArgumentError, "TEST: unknown endianness: BLAH - Must be :BIG_ENDIAN or :LITTLE_ENDIAN")
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "data_type=" do
|
46
|
-
it "
|
46
|
+
it "accepts INT, UINT, FLOAT, STRING, BLOCK, and DERIVED data types" do
|
47
47
|
%w(INT UINT FLOAT STRING BLOCK).each do |type|
|
48
|
-
StructureItem.new("test", 0, 32, type.to_sym, :BIG_ENDIAN, nil).data_type.
|
48
|
+
expect(StructureItem.new("test", 0, 32, type.to_sym, :BIG_ENDIAN, nil).data_type).to eql type.to_sym
|
49
49
|
end
|
50
|
-
StructureItem.new("test", 0, 0, :DERIVED, :BIG_ENDIAN, nil).data_type.
|
50
|
+
expect(StructureItem.new("test", 0, 0, :DERIVED, :BIG_ENDIAN, nil).data_type).to eql :DERIVED
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "complains about bad data types" do
|
54
54
|
expect { StructureItem.new("test", 0, 0, :UNKNOWN, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: unknown data_type: UNKNOWN - Must be :INT, :UINT, :FLOAT, :STRING, :BLOCK, or :DERIVED")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "overflow=" do
|
59
|
-
it "
|
59
|
+
it "accepts ERROR, ERROR_ALLOW_HEX, TRUNCATE and SATURATE overflow types" do
|
60
60
|
%w(ERROR ERROR_ALLOW_HEX TRUNCATE SATURATE).each do |type|
|
61
|
-
StructureItem.new("test", 0, 32, :INT, :BIG_ENDIAN, nil, type.to_sym).overflow.
|
61
|
+
expect(StructureItem.new("test", 0, 32, :INT, :BIG_ENDIAN, nil, type.to_sym).overflow).to eql type.to_sym
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
65
|
+
it "complains about bad overflow types" do
|
66
66
|
expect { StructureItem.new("test", 0, 32, :INT, :BIG_ENDIAN, nil, :UNKNOWN) }.to raise_error(ArgumentError, "TEST: unknown overflow type: UNKNOWN - Must be :ERROR, :ERROR_ALLOW_HEX, :TRUNCATE, or :SATURATE")
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "bit_offset=" do
|
71
|
-
it "
|
71
|
+
it "compains about bad bit offsets types" do
|
72
72
|
expect { StructureItem.new("test", nil, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_offset must be a Fixnum")
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
75
|
+
it "complains about unaligned bit offsets" do
|
76
76
|
%w(FLOAT STRING BLOCK).each do |type|
|
77
77
|
expect { StructureItem.new("test", 1, 32, type.to_sym, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_offset for :FLOAT, :STRING, and :BLOCK items must be byte aligned")
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
it "
|
81
|
+
it "complains about non zero DERIVED bit offsets" do
|
82
82
|
expect { StructureItem.new("test", 8, 0, :DERIVED, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: DERIVED items must have bit_offset of zero")
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "bit_size=" do
|
87
|
-
it "
|
87
|
+
it "complains about bad bit sizes types" do
|
88
88
|
expect { StructureItem.new("test", 0, nil, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_size must be a Fixnum")
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
91
|
+
it "complains about 0 size INT, UINT, and FLOAT" do
|
92
92
|
%w(INT UINT FLOAT).each do |type|
|
93
93
|
expect { StructureItem.new("test", 0, 0, type.to_sym, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_size cannot be negative or zero for :INT, :UINT, and :FLOAT items: 0")
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
it "
|
97
|
+
it "complains about bad float bit sizes" do
|
98
98
|
expect { StructureItem.new("test", 0, 8, :FLOAT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_size for FLOAT items must be 32 or 64. Given: 8")
|
99
99
|
end
|
100
100
|
|
101
|
-
it "
|
102
|
-
StructureItem.new("test", 0, 32, :FLOAT, :BIG_ENDIAN, nil).bit_size.
|
103
|
-
StructureItem.new("test", 0, 64, :FLOAT, :BIG_ENDIAN, nil).bit_size.
|
101
|
+
it "creates 32 and 64 bit floats" do
|
102
|
+
expect(StructureItem.new("test", 0, 32, :FLOAT, :BIG_ENDIAN, nil).bit_size).to eql 32
|
103
|
+
expect(StructureItem.new("test", 0, 64, :FLOAT, :BIG_ENDIAN, nil).bit_size).to eql 64
|
104
104
|
end
|
105
105
|
|
106
|
-
it "
|
106
|
+
it "complains about non zero DERIVED bit sizes" do
|
107
107
|
expect { StructureItem.new("test", 0, 8, :DERIVED, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: DERIVED items must have bit_size of zero")
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
describe "array_size=" do
|
112
|
-
it "
|
112
|
+
it "complains about bad array size types" do
|
113
113
|
expect { StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, "") }.to raise_error(ArgumentError, "TEST: array_size must be a Fixnum")
|
114
114
|
end
|
115
115
|
|
116
|
-
it "
|
116
|
+
it "complains about array size != multiple of bit size" do
|
117
117
|
expect { StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, 10) }.to raise_error(ArgumentError, "TEST: array_size must be a multiple of bit_size")
|
118
118
|
end
|
119
119
|
|
120
|
-
it "
|
120
|
+
it "does not complain about array size != multiple of bit size with negative array size" do
|
121
121
|
expect { StructureItem.new("test", 0, 32, :UINT, :BIG_ENDIAN, -8) }.not_to raise_error
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
125
|
describe "<=>" do
|
126
|
-
it "
|
126
|
+
it "sorts items according to positive bit offset" do
|
127
127
|
si1 = StructureItem.new("si1", 0, 8, :UINT, :BIG_ENDIAN, nil)
|
128
128
|
si2 = StructureItem.new("si2", 8, 8, :UINT, :BIG_ENDIAN, nil)
|
129
|
-
(si1 < si2).
|
130
|
-
(si1 == si2).
|
131
|
-
(si1 > si2).
|
129
|
+
expect(si1 < si2).to be_truthy
|
130
|
+
expect(si1 == si2).to be_falsey
|
131
|
+
expect(si1 > si2).to be_falsey
|
132
132
|
|
133
133
|
si2 = StructureItem.new("si2", 0, 8, :UINT, :BIG_ENDIAN, nil)
|
134
|
-
(si1 < si2).
|
135
|
-
(si1 == si2).
|
136
|
-
(si1 > si2).
|
134
|
+
expect(si1 < si2).to be_falsey
|
135
|
+
expect(si1 == si2).to be_truthy
|
136
|
+
expect(si1 > si2).to be_falsey
|
137
137
|
end
|
138
138
|
|
139
|
-
it "
|
139
|
+
it "sorts items with 0 bit offset according to bit size" do
|
140
140
|
si1 = StructureItem.new("si1", 0, 8, :UINT, :BIG_ENDIAN, nil)
|
141
141
|
si2 = StructureItem.new("si2", 0, 0, :BLOCK, :BIG_ENDIAN, nil)
|
142
|
-
(si1 < si2).
|
143
|
-
(si1 == si2).
|
144
|
-
(si1 > si2).
|
142
|
+
expect(si1 < si2).to be_falsey
|
143
|
+
expect(si1 == si2).to be_falsey
|
144
|
+
expect(si1 > si2).to be_truthy
|
145
145
|
end
|
146
146
|
|
147
|
-
it "
|
147
|
+
it "sorts items according to negative bit offset" do
|
148
148
|
si1 = StructureItem.new("si1", -8, 8, :UINT, :BIG_ENDIAN, nil)
|
149
149
|
si2 = StructureItem.new("si2", -16, 8, :UINT, :BIG_ENDIAN, nil)
|
150
|
-
(si1 < si2).
|
151
|
-
(si1 == si2).
|
152
|
-
(si1 > si2).
|
150
|
+
expect(si1 < si2).to be_falsey
|
151
|
+
expect(si1 == si2).to be_falsey
|
152
|
+
expect(si1 > si2).to be_truthy
|
153
153
|
|
154
154
|
si2 = StructureItem.new("si2", -8, 8, :UINT, :BIG_ENDIAN, nil)
|
155
|
-
(si1 < si2).
|
155
|
+
expect(si1 < si2).to be_falsey
|
156
156
|
# si1 == si2 even though they have different names and sizes
|
157
|
-
(si1 == si2).
|
158
|
-
(si1 > si2).
|
157
|
+
expect(si1 == si2).to be_truthy
|
158
|
+
expect(si1 > si2).to be_falsey
|
159
159
|
end
|
160
160
|
|
161
|
-
it "
|
161
|
+
it "sorts items according to mixed bit offset" do
|
162
162
|
si1 = StructureItem.new("si1", 16, 8, :UINT, :BIG_ENDIAN, nil)
|
163
163
|
si2 = StructureItem.new("si2", -8, 8, :UINT, :BIG_ENDIAN, nil)
|
164
|
-
(si1 < si2).
|
165
|
-
(si1 == si2).
|
166
|
-
(si1 > si2).
|
164
|
+
expect(si1 < si2).to be_truthy
|
165
|
+
expect(si1 == si2).to be_falsey
|
166
|
+
expect(si1 > si2).to be_falsey
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
170
|
describe "clone" do
|
171
|
-
it "
|
171
|
+
it "duplicates the entire structure item " do
|
172
172
|
si1 = StructureItem.new("si1", -8, 1, :UINT, :LITTLE_ENDIAN, nil)
|
173
173
|
si2 = si1.clone
|
174
|
-
(si1 == si2).
|
174
|
+
expect(si1 == si2).to be_truthy
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
178
|
describe "to_hash" do
|
179
|
-
it "
|
179
|
+
it "creates a Hash" do
|
180
180
|
item = StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, 16)
|
181
181
|
hash = item.to_hash
|
182
|
-
hash.keys.length.
|
183
|
-
hash.keys.
|
184
|
-
hash["name"].
|
185
|
-
hash["bit_offset"].
|
186
|
-
hash["bit_size"].
|
187
|
-
hash["data_type"].
|
188
|
-
hash["endianness"].
|
189
|
-
hash["array_size"].
|
190
|
-
hash["overflow"].
|
182
|
+
expect(hash.keys.length).to eql 7
|
183
|
+
expect(hash.keys).to include('name','bit_offset','bit_size','data_type','endianness','array_size', 'overflow')
|
184
|
+
expect(hash["name"]).to eql "TEST"
|
185
|
+
expect(hash["bit_offset"]).to eql 0
|
186
|
+
expect(hash["bit_size"]).to eql 8
|
187
|
+
expect(hash["data_type"]).to eql :UINT
|
188
|
+
expect(hash["endianness"]).to eql :BIG_ENDIAN
|
189
|
+
expect(hash["array_size"]).to eql 16
|
190
|
+
expect(hash["overflow"]).to eql :ERROR
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
@@ -17,20 +17,20 @@ module Cosmos
|
|
17
17
|
describe Structure do
|
18
18
|
|
19
19
|
describe "initialize" do
|
20
|
-
it "
|
20
|
+
it "complains about non string buffers" do
|
21
21
|
expect { Structure.new(:BIG_ENDIAN, Array.new) }.to raise_error(TypeError, "wrong argument type Array (expected String)")
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "complains about unrecognized data types" do
|
25
25
|
expect { Structure.new(:BLAH) }.to raise_error(ArgumentError, "Unrecognized endianness: BLAH - Must be :BIG_ENDIAN or :LITTLE_ENDIAN")
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
Structure.new(:BIG_ENDIAN).default_endianness.
|
28
|
+
it "creates BIG_ENDIAN structures" do
|
29
|
+
expect(Structure.new(:BIG_ENDIAN).default_endianness).to eql :BIG_ENDIAN
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
33
|
-
Structure.new(:LITTLE_ENDIAN).default_endianness.
|
32
|
+
it "creates LITTLE_ENDIAN structures" do
|
33
|
+
expect(Structure.new(:LITTLE_ENDIAN).default_endianness).to eql :LITTLE_ENDIAN
|
34
34
|
end
|
35
35
|
end # describe "initialize"
|
36
36
|
|
@@ -46,16 +46,16 @@ module Cosmos
|
|
46
46
|
describe "rename_item" do
|
47
47
|
it "renames a previously defined item" do
|
48
48
|
s = Structure.new
|
49
|
-
s.items["test1"].
|
50
|
-
s.sorted_items[0].
|
49
|
+
expect(s.items["test1"]).to be_nil
|
50
|
+
expect(s.sorted_items[0]).to be_nil
|
51
51
|
s.define_item("test1", 0, 8, :UINT)
|
52
|
-
s.items["TEST1"].
|
53
|
-
s.sorted_items[0].
|
54
|
-
s.sorted_items[0].name.
|
52
|
+
expect(s.items["TEST1"]).not_to be_nil
|
53
|
+
expect(s.sorted_items[0]).not_to be_nil
|
54
|
+
expect(s.sorted_items[0].name).to eql "TEST1"
|
55
55
|
s.rename_item("TEST1", "TEST2")
|
56
|
-
s.items["TEST1"].
|
57
|
-
s.items["TEST2"].
|
58
|
-
s.sorted_items[0].name.
|
56
|
+
expect(s.items["TEST1"]).to be_nil
|
57
|
+
expect(s.items["TEST2"]).not_to be_nil
|
58
|
+
expect(s.sorted_items[0].name).to eql "TEST2"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -64,32 +64,32 @@ module Cosmos
|
|
64
64
|
@s = Structure.new
|
65
65
|
end
|
66
66
|
|
67
|
-
it "
|
68
|
-
@s.items["test1"].
|
69
|
-
@s.sorted_items[0].
|
67
|
+
it "adds item to items and sorted_items" do
|
68
|
+
expect(@s.items["test1"]).to be_nil
|
69
|
+
expect(@s.sorted_items[0]).to be_nil
|
70
70
|
@s.define_item("test1", 0, 8, :UINT)
|
71
|
-
@s.items["TEST1"].
|
72
|
-
@s.sorted_items[0].
|
73
|
-
@s.sorted_items[0].name.
|
74
|
-
@s.defined_length.
|
75
|
-
@s.fixed_size.
|
71
|
+
expect(@s.items["TEST1"]).not_to be_nil
|
72
|
+
expect(@s.sorted_items[0]).not_to be_nil
|
73
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
74
|
+
expect(@s.defined_length).to eql 1
|
75
|
+
expect(@s.fixed_size).to be true
|
76
76
|
end
|
77
77
|
|
78
78
|
it "adds items with negative bit offsets" do
|
79
79
|
@s.define_item("test1", -8, 8, :UINT)
|
80
|
-
@s.defined_length.
|
80
|
+
expect(@s.defined_length).to eql 1
|
81
81
|
@s.define_item("test2", 0, 4, :UINT)
|
82
|
-
@s.defined_length.
|
82
|
+
expect(@s.defined_length).to eql 2
|
83
83
|
@s.define_item("test3", 4, 4, :UINT)
|
84
|
-
@s.defined_length.
|
84
|
+
expect(@s.defined_length).to eql 2
|
85
85
|
@s.define_item("test4", 16, 0, :BLOCK)
|
86
|
-
@s.defined_length.
|
86
|
+
expect(@s.defined_length).to eql 3
|
87
87
|
@s.define_item("test5", -16, 8, :UINT)
|
88
|
-
@s.defined_length.
|
89
|
-
@s.fixed_size.
|
88
|
+
expect(@s.defined_length).to eql 4
|
89
|
+
expect(@s.fixed_size).to be false
|
90
90
|
end
|
91
91
|
|
92
|
-
it "
|
92
|
+
it "adds item with negative offset" do
|
93
93
|
expect { @s.define_item("test11", -64, 8, :UINT, 128) }.to raise_error(ArgumentError, "TEST11: Can't define an item with array_size 128 greater than negative bit_offset -64")
|
94
94
|
expect { @s.define_item("test10", -64, 8, :UINT, -64) }.to raise_error(ArgumentError, "TEST10: Can't define an item with negative array_size -64 and negative bit_offset -64")
|
95
95
|
expect { @s.define_item("test9", -64, -64, :BLOCK) }.to raise_error(ArgumentError, "TEST9: Can't define an item with negative bit_size -64 and negative bit_offset -64")
|
@@ -97,43 +97,43 @@ module Cosmos
|
|
97
97
|
expect { @s.define_item("test7", 0, 0, :BLOCK, 64) }.to raise_error(ArgumentError, "TEST7: bit_size cannot be negative or zero for array items")
|
98
98
|
expect { @s.define_item("test6", -24, 32, :UINT) }.to raise_error(ArgumentError, "TEST6: Can't define an item with bit_size 32 greater than negative bit_offset -24")
|
99
99
|
@s.define_item("test5", -16, 8, :UINT)
|
100
|
-
@s.defined_length.
|
100
|
+
expect(@s.defined_length).to eql 2
|
101
101
|
@s.define_item("test1", -8, 8, :UINT)
|
102
|
-
@s.defined_length.
|
102
|
+
expect(@s.defined_length).to eql 2
|
103
103
|
@s.define_item("test2", 0, 4, :UINT)
|
104
|
-
@s.defined_length.
|
104
|
+
expect(@s.defined_length).to eql 3
|
105
105
|
@s.define_item("test3", 4, 4, :UINT)
|
106
|
-
@s.defined_length.
|
106
|
+
expect(@s.defined_length).to eql 3
|
107
107
|
@s.define_item("test4", 8, 0, :BLOCK)
|
108
|
-
@s.defined_length.
|
109
|
-
@s.fixed_size.
|
108
|
+
expect(@s.defined_length).to eql 3
|
109
|
+
expect(@s.fixed_size).to be false
|
110
110
|
end
|
111
111
|
|
112
|
-
it "
|
112
|
+
it "recalulates sorted_items when adding multiple items" do
|
113
113
|
@s.define_item("test1", 8, 32, :UINT)
|
114
|
-
@s.sorted_items[0].name.
|
115
|
-
@s.defined_length.
|
114
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
115
|
+
expect(@s.defined_length).to eql 5
|
116
116
|
@s.define_item("test2", 0, 8, :UINT)
|
117
|
-
@s.sorted_items[0].name.
|
118
|
-
@s.defined_length.
|
117
|
+
expect(@s.sorted_items[0].name).to eql "TEST2"
|
118
|
+
expect(@s.defined_length).to eql 5
|
119
119
|
@s.define_item("test3", 16, 8, :UINT)
|
120
|
-
@s.sorted_items[-1].name.
|
121
|
-
@s.defined_length.
|
122
|
-
@s.fixed_size.
|
120
|
+
expect(@s.sorted_items[-1].name).to eql "TEST3"
|
121
|
+
expect(@s.defined_length).to eql 5
|
122
|
+
expect(@s.fixed_size).to be true
|
123
123
|
end
|
124
124
|
|
125
|
-
it "
|
125
|
+
it "overwrites existing items" do
|
126
126
|
@s.define_item("test1", 0, 8, :UINT)
|
127
|
-
@s.sorted_items[0].name.
|
128
|
-
@s.items["TEST1"].bit_size.
|
129
|
-
@s.items["TEST1"].data_type.
|
130
|
-
@s.defined_length.
|
127
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
128
|
+
expect(@s.items["TEST1"].bit_size).to eql 8
|
129
|
+
expect(@s.items["TEST1"].data_type).to eql :UINT
|
130
|
+
expect(@s.defined_length).to eql 1
|
131
131
|
@s.define_item("test1", 0, 16, :INT)
|
132
|
-
@s.sorted_items[0].name.
|
133
|
-
@s.items["TEST1"].bit_size.
|
134
|
-
@s.items["TEST1"].data_type.
|
135
|
-
@s.defined_length.
|
136
|
-
@s.fixed_size.
|
132
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
133
|
+
expect(@s.items["TEST1"].bit_size).to eql 16
|
134
|
+
expect(@s.items["TEST1"].data_type).to eql :INT
|
135
|
+
expect(@s.defined_length).to eql 2
|
136
|
+
expect(@s.fixed_size).to be true
|
137
137
|
end
|
138
138
|
end # describe "define_item"
|
139
139
|
|
@@ -143,53 +143,53 @@ module Cosmos
|
|
143
143
|
end
|
144
144
|
|
145
145
|
it "adds the item to items and sorted_items" do
|
146
|
-
@s.items["test1"].
|
147
|
-
@s.sorted_items[0].
|
146
|
+
expect(@s.items["test1"]).to be_nil
|
147
|
+
expect(@s.sorted_items[0]).to be_nil
|
148
148
|
si = StructureItem.new("test1",0,8,:UINT,:BIG_ENDIAN)
|
149
149
|
@s.define(si)
|
150
|
-
@s.items["TEST1"].
|
151
|
-
@s.sorted_items[0].
|
152
|
-
@s.sorted_items[0].name.
|
153
|
-
@s.defined_length.
|
154
|
-
@s.fixed_size.
|
150
|
+
expect(@s.items["TEST1"]).not_to be_nil
|
151
|
+
expect(@s.sorted_items[0]).not_to be_nil
|
152
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
153
|
+
expect(@s.defined_length).to eql 1
|
154
|
+
expect(@s.fixed_size).to be true
|
155
155
|
end
|
156
156
|
|
157
157
|
it "allows items to be defined on top of each other" do
|
158
|
-
@s.items["test1"].
|
159
|
-
@s.sorted_items[0].
|
158
|
+
expect(@s.items["test1"]).to be_nil
|
159
|
+
expect(@s.sorted_items[0]).to be_nil
|
160
160
|
si = StructureItem.new("test1",0,8,:UINT,:BIG_ENDIAN)
|
161
161
|
@s.define(si)
|
162
|
-
@s.sorted_items[0].name.
|
163
|
-
@s.items["TEST1"].bit_offset.
|
164
|
-
@s.items["TEST1"].bit_size.
|
165
|
-
@s.items["TEST1"].data_type.
|
166
|
-
@s.defined_length.
|
162
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
163
|
+
expect(@s.items["TEST1"].bit_offset).to eql 0
|
164
|
+
expect(@s.items["TEST1"].bit_size).to eql 8
|
165
|
+
expect(@s.items["TEST1"].data_type).to eql :UINT
|
166
|
+
expect(@s.defined_length).to eql 1
|
167
167
|
si = StructureItem.new("test2",0,16,:INT,:BIG_ENDIAN)
|
168
168
|
@s.define(si)
|
169
|
-
@s.sorted_items[1].name.
|
170
|
-
@s.items["TEST2"].bit_offset.
|
171
|
-
@s.items["TEST2"].bit_size.
|
172
|
-
@s.items["TEST2"].data_type.
|
173
|
-
@s.defined_length.
|
169
|
+
expect(@s.sorted_items[1].name).to eql "TEST2"
|
170
|
+
expect(@s.items["TEST2"].bit_offset).to eql 0
|
171
|
+
expect(@s.items["TEST2"].bit_size).to eql 16
|
172
|
+
expect(@s.items["TEST2"].data_type).to eql :INT
|
173
|
+
expect(@s.defined_length).to eql 2
|
174
174
|
buffer = "\x01\x02"
|
175
|
-
@s.read_item(@s.get_item("test1"), :RAW, buffer).
|
176
|
-
@s.read_item(@s.get_item("test2"), :RAW, buffer).
|
175
|
+
expect(@s.read_item(@s.get_item("test1"), :RAW, buffer)).to eql 1
|
176
|
+
expect(@s.read_item(@s.get_item("test2"), :RAW, buffer)).to eql 258
|
177
177
|
end
|
178
178
|
|
179
|
-
it "
|
179
|
+
it "overwrites existing items" do
|
180
180
|
si = StructureItem.new("test1",0,8,:UINT,:BIG_ENDIAN)
|
181
181
|
@s.define(si)
|
182
|
-
@s.sorted_items[0].name.
|
183
|
-
@s.items["TEST1"].bit_size.
|
184
|
-
@s.items["TEST1"].data_type.
|
185
|
-
@s.defined_length.
|
182
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
183
|
+
expect(@s.items["TEST1"].bit_size).to eql 8
|
184
|
+
expect(@s.items["TEST1"].data_type).to eql :UINT
|
185
|
+
expect(@s.defined_length).to eql 1
|
186
186
|
si = StructureItem.new("test1",0,16,:INT,:BIG_ENDIAN)
|
187
187
|
@s.define(si)
|
188
|
-
@s.sorted_items[0].name.
|
189
|
-
@s.items["TEST1"].bit_size.
|
190
|
-
@s.items["TEST1"].data_type.
|
191
|
-
@s.defined_length.
|
192
|
-
@s.fixed_size.
|
188
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
189
|
+
expect(@s.items["TEST1"].bit_size).to eql 16
|
190
|
+
expect(@s.items["TEST1"].data_type).to eql :INT
|
191
|
+
expect(@s.defined_length).to eql 2
|
192
|
+
expect(@s.fixed_size).to be true
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
@@ -198,34 +198,34 @@ module Cosmos
|
|
198
198
|
@s = Structure.new
|
199
199
|
end
|
200
200
|
|
201
|
-
it "
|
201
|
+
it "appends an item to items" do
|
202
202
|
@s.define_item("test1", 0, 8, :UINT)
|
203
203
|
@s.append_item("test2", 16, :UINT)
|
204
|
-
@s.items["TEST2"].bit_size.
|
205
|
-
@s.sorted_items[0].name.
|
206
|
-
@s.sorted_items[1].name.
|
207
|
-
@s.defined_length.
|
204
|
+
expect(@s.items["TEST2"].bit_size).to eql 16
|
205
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
206
|
+
expect(@s.sorted_items[1].name).to eql "TEST2"
|
207
|
+
expect(@s.defined_length).to eql 3
|
208
208
|
end
|
209
209
|
|
210
|
-
it "
|
210
|
+
it "appends an item after an array item " do
|
211
211
|
@s.define_item("test1", 0, 8, :UINT, 16)
|
212
|
-
@s.items["TEST1"].bit_size.
|
213
|
-
@s.sorted_items[0].name.
|
214
|
-
@s.sorted_items[1].
|
215
|
-
@s.defined_length.
|
212
|
+
expect(@s.items["TEST1"].bit_size).to eql 8
|
213
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
214
|
+
expect(@s.sorted_items[1]).to be_nil
|
215
|
+
expect(@s.defined_length).to eql 2
|
216
216
|
@s.append_item("test2", 16, :UINT)
|
217
|
-
@s.items["TEST2"].bit_size.
|
218
|
-
@s.sorted_items[0].name.
|
219
|
-
@s.sorted_items[1].name.
|
220
|
-
@s.defined_length.
|
217
|
+
expect(@s.items["TEST2"].bit_size).to eql 16
|
218
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
219
|
+
expect(@s.sorted_items[1].name).to eql "TEST2"
|
220
|
+
expect(@s.defined_length).to eql 4
|
221
221
|
end
|
222
222
|
|
223
|
-
it "
|
223
|
+
it "complains if appending after a variably sized item" do
|
224
224
|
@s.define_item("test1", 0, 0, :BLOCK)
|
225
225
|
expect { @s.append_item("test2", 8, :UINT) }.to raise_error(ArgumentError, "Can't append an item after a variably sized item")
|
226
226
|
end
|
227
227
|
|
228
|
-
it "
|
228
|
+
it "complains if appending after a variably sized array" do
|
229
229
|
@s.define_item("test1", 0, 8, :UINT, -8)
|
230
230
|
expect { @s.append_item("test2", 8, :UINT) }.to raise_error(ArgumentError, "Can't append an item after a variably sized item")
|
231
231
|
end
|
@@ -241,13 +241,13 @@ module Cosmos
|
|
241
241
|
item = StructureItem.new("test2", 0, 16, :UINT, :BIG_ENDIAN)
|
242
242
|
@s.append(item)
|
243
243
|
# Bit offset should change because we appended the item
|
244
|
-
@s.items["TEST2"].bit_offset.
|
245
|
-
@s.sorted_items[0].name.
|
246
|
-
@s.sorted_items[1].name.
|
247
|
-
@s.defined_length.
|
244
|
+
expect(@s.items["TEST2"].bit_offset).to eql 8
|
245
|
+
expect(@s.sorted_items[0].name).to eql "TEST1"
|
246
|
+
expect(@s.sorted_items[1].name).to eql "TEST2"
|
247
|
+
expect(@s.defined_length).to eql 3
|
248
248
|
end
|
249
249
|
|
250
|
-
it "
|
250
|
+
it "complains if appending after a variably sized item" do
|
251
251
|
@s.define_item("test1", 0, 0, :BLOCK)
|
252
252
|
expect { @s.append(@item) }.to raise_error(ArgumentError, "Can't append an item after a variably sized item")
|
253
253
|
end
|
@@ -259,11 +259,11 @@ module Cosmos
|
|
259
259
|
@s.define_item("test1", 0, 8, :UINT)
|
260
260
|
end
|
261
261
|
|
262
|
-
it "
|
263
|
-
@s.get_item("test1").
|
262
|
+
it "returns a defined item" do
|
263
|
+
expect(@s.get_item("test1")).not_to be_nil
|
264
264
|
end
|
265
265
|
|
266
|
-
it "
|
266
|
+
it "complains if an item doesn't exist" do
|
267
267
|
expect { @s.get_item("test2") }.to raise_error(ArgumentError, "Unknown item: test2")
|
268
268
|
end
|
269
269
|
end
|
@@ -274,15 +274,15 @@ module Cosmos
|
|
274
274
|
@s.define_item("test1", 0, 8, :UINT)
|
275
275
|
end
|
276
276
|
|
277
|
-
it "
|
277
|
+
it "sets a defined item" do
|
278
278
|
item = @s.get_item("test1")
|
279
|
-
item.bit_size.
|
279
|
+
expect(item.bit_size).to eql 8
|
280
280
|
item.bit_size = 16
|
281
281
|
@s.set_item(item)
|
282
|
-
@s.get_item("test1").bit_size.
|
282
|
+
expect(@s.get_item("test1").bit_size).to eql 16
|
283
283
|
end
|
284
284
|
|
285
|
-
it "
|
285
|
+
it "complains if an item doesn't exist" do
|
286
286
|
item = @s.get_item("test1")
|
287
287
|
item.name = "TEST2"
|
288
288
|
expect { @s.set_item(item) }.to raise_error(ArgumentError, "Unknown item: TEST2 - Ensure item name is uppercase")
|
@@ -290,92 +290,92 @@ module Cosmos
|
|
290
290
|
end
|
291
291
|
|
292
292
|
describe "read_item" do
|
293
|
-
it "
|
293
|
+
it "complains if no buffer given" do
|
294
294
|
s = Structure.new
|
295
295
|
s.define_item("test1", 0, 8, :UINT)
|
296
296
|
expect { s.read_item(s.get_item("test1"), :RAW, nil) }.to raise_error(RuntimeError, "No buffer given to read_item")
|
297
297
|
end
|
298
298
|
|
299
|
-
it "
|
299
|
+
it "reads data from the buffer" do
|
300
300
|
s = Structure.new
|
301
301
|
s.define_item("test1", 0, 8, :UINT)
|
302
302
|
buffer = "\x01"
|
303
|
-
s.read_item(s.get_item("test1"), :RAW, buffer).
|
303
|
+
expect(s.read_item(s.get_item("test1"), :RAW, buffer)).to eql 1
|
304
304
|
end
|
305
305
|
|
306
|
-
it "
|
306
|
+
it "reads array data from the buffer" do
|
307
307
|
s = Structure.new
|
308
308
|
s.define_item("test1", 0, 8, :UINT, 16)
|
309
309
|
buffer = "\x01\x02"
|
310
|
-
s.read_item(s.get_item("test1"), :RAW, buffer).
|
310
|
+
expect(s.read_item(s.get_item("test1"), :RAW, buffer)).to eql [1,2]
|
311
311
|
end
|
312
312
|
end
|
313
313
|
|
314
314
|
describe "write_item" do
|
315
|
-
it "
|
315
|
+
it "complains if no buffer given" do
|
316
316
|
expect { Structure.new.write_item(nil, nil, nil, nil) }.to raise_error(RuntimeError, "No buffer given to write_item")
|
317
317
|
end
|
318
318
|
|
319
|
-
it "
|
319
|
+
it "writes data to the buffer" do
|
320
320
|
s = Structure.new
|
321
321
|
s.define_item("test1", 0, 8, :UINT)
|
322
322
|
buffer = "\x01"
|
323
|
-
s.read_item(s.get_item("test1"), :RAW, buffer).
|
323
|
+
expect(s.read_item(s.get_item("test1"), :RAW, buffer)).to eql 1
|
324
324
|
s.write_item(s.get_item("test1"), 2, :RAW, buffer)
|
325
|
-
s.read_item(s.get_item("test1"), :RAW, buffer).
|
325
|
+
expect(s.read_item(s.get_item("test1"), :RAW, buffer)).to eql 2
|
326
326
|
end
|
327
327
|
|
328
|
-
it "
|
328
|
+
it "writes array data to the buffer" do
|
329
329
|
s = Structure.new
|
330
330
|
s.define_item("test1", 0, 8, :UINT, 16)
|
331
331
|
buffer = "\x01\x02"
|
332
|
-
s.read_item(s.get_item("test1"), :RAW, buffer).
|
332
|
+
expect(s.read_item(s.get_item("test1"), :RAW, buffer)).to eql [1,2]
|
333
333
|
s.write_item(s.get_item("test1"), [3,4], :RAW, buffer)
|
334
|
-
s.read_item(s.get_item("test1"), :RAW, buffer).
|
334
|
+
expect(s.read_item(s.get_item("test1"), :RAW, buffer)).to eql [3,4]
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
338
|
describe "read" do
|
339
|
-
it "
|
339
|
+
it "complains if item doesn't exist" do
|
340
340
|
expect { Structure.new.read("BLAH") }.to raise_error(ArgumentError, "Unknown item: BLAH")
|
341
341
|
end
|
342
342
|
|
343
|
-
it "
|
343
|
+
it "reads data from the buffer" do
|
344
344
|
s = Structure.new
|
345
345
|
s.define_item("test1", 0, 8, :UINT)
|
346
346
|
buffer = "\x01"
|
347
|
-
s.read("test1", :RAW, buffer).
|
347
|
+
expect(s.read("test1", :RAW, buffer)).to eql 1
|
348
348
|
end
|
349
349
|
|
350
|
-
it "
|
350
|
+
it "reads array data from the buffer" do
|
351
351
|
s = Structure.new
|
352
352
|
s.define_item("test1", 0, 8, :UINT, 16)
|
353
353
|
buffer = "\x01\x02"
|
354
|
-
s.read("test1", :RAW, buffer).
|
354
|
+
expect(s.read("test1", :RAW, buffer)).to eql [1,2]
|
355
355
|
end
|
356
356
|
end
|
357
357
|
|
358
358
|
describe "write" do
|
359
|
-
it "
|
359
|
+
it "complains if item doesn't exist" do
|
360
360
|
expect { Structure.new.write("BLAH", 0) }.to raise_error(ArgumentError, "Unknown item: BLAH")
|
361
361
|
end
|
362
362
|
|
363
|
-
it "
|
363
|
+
it "writes data to the buffer" do
|
364
364
|
s = Structure.new
|
365
365
|
s.define_item("test1", 0, 8, :UINT)
|
366
366
|
buffer = "\x01"
|
367
|
-
s.read("test1", :RAW, buffer).
|
367
|
+
expect(s.read("test1", :RAW, buffer)).to eql 1
|
368
368
|
s.write("test1", 2, :RAW, buffer)
|
369
|
-
s.read("test1", :RAW, buffer).
|
369
|
+
expect(s.read("test1", :RAW, buffer)).to eql 2
|
370
370
|
end
|
371
371
|
|
372
|
-
it "
|
372
|
+
it "writes array data to the buffer" do
|
373
373
|
s = Structure.new
|
374
374
|
s.define_item("test1", 0, 8, :UINT, 16)
|
375
375
|
buffer = "\x01\x02"
|
376
|
-
s.read("test1", :RAW, buffer).
|
376
|
+
expect(s.read("test1", :RAW, buffer)).to eql [1,2]
|
377
377
|
s.write("test1", [3,4], :RAW, buffer)
|
378
|
-
s.read("test1", :RAW, buffer).
|
378
|
+
expect(s.read("test1", :RAW, buffer)).to eql [3,4]
|
379
379
|
end
|
380
380
|
end
|
381
381
|
|
@@ -388,12 +388,12 @@ module Cosmos
|
|
388
388
|
|
389
389
|
buffer = "\x01\x02\x03\x04\x05\x06\x07\x08"
|
390
390
|
vals = s.read_all(:RAW, buffer)
|
391
|
-
vals[0][0].
|
392
|
-
vals[1][0].
|
393
|
-
vals[2][0].
|
394
|
-
vals[0][1].
|
395
|
-
vals[1][1].
|
396
|
-
vals[2][1].
|
391
|
+
expect(vals[0][0]).to eql "TEST1"
|
392
|
+
expect(vals[1][0]).to eql "TEST2"
|
393
|
+
expect(vals[2][0]).to eql "TEST3"
|
394
|
+
expect(vals[0][1]).to eql [1,2]
|
395
|
+
expect(vals[1][1]).to eql 0x0304
|
396
|
+
expect(vals[2][1]).to eql 0x05060708
|
397
397
|
end
|
398
398
|
|
399
399
|
it "reads all defined items synchronized" do
|
@@ -404,17 +404,17 @@ module Cosmos
|
|
404
404
|
|
405
405
|
buffer = "\x01\x02\x03\x04\x05\x06\x07\x08"
|
406
406
|
vals = s.read_all(:RAW, buffer, false)
|
407
|
-
vals[0][0].
|
408
|
-
vals[1][0].
|
409
|
-
vals[2][0].
|
410
|
-
vals[0][1].
|
411
|
-
vals[1][1].
|
412
|
-
vals[2][1].
|
407
|
+
expect(vals[0][0]).to eql "TEST1"
|
408
|
+
expect(vals[1][0]).to eql "TEST2"
|
409
|
+
expect(vals[2][0]).to eql "TEST3"
|
410
|
+
expect(vals[0][1]).to eql [1,2]
|
411
|
+
expect(vals[1][1]).to eql 0x0304
|
412
|
+
expect(vals[2][1]).to eql 0x05060708
|
413
413
|
end
|
414
414
|
end
|
415
415
|
|
416
416
|
describe "formatted" do
|
417
|
-
it "
|
417
|
+
it "prints out all the items and values" do
|
418
418
|
s = Structure.new(:BIG_ENDIAN)
|
419
419
|
s.append_item("test1", 8, :UINT, 16)
|
420
420
|
s.write("test1", [1,2])
|
@@ -422,13 +422,13 @@ module Cosmos
|
|
422
422
|
s.write("test2", 3456)
|
423
423
|
s.append_item("test3", 32, :BLOCK)
|
424
424
|
s.write("test3", "\x07\x08\x09\x0A")
|
425
|
-
s.formatted.
|
426
|
-
s.formatted.
|
427
|
-
s.formatted.
|
428
|
-
s.formatted.
|
425
|
+
expect(s.formatted).to include("TEST1: [1, 2]")
|
426
|
+
expect(s.formatted).to include("TEST2: 3456")
|
427
|
+
expect(s.formatted).to include("TEST3")
|
428
|
+
expect(s.formatted).to include("00000000: 07 08 09 0A")
|
429
429
|
end
|
430
430
|
|
431
|
-
it "
|
431
|
+
it "alters the indentation of the item" do
|
432
432
|
s = Structure.new(:BIG_ENDIAN)
|
433
433
|
s.append_item("test1", 8, :UINT, 16)
|
434
434
|
s.write("test1", [1,2])
|
@@ -436,10 +436,10 @@ module Cosmos
|
|
436
436
|
s.write("test2", 3456)
|
437
437
|
s.append_item("test3", 32, :BLOCK)
|
438
438
|
s.write("test3", "\x07\x08\x09\x0A")
|
439
|
-
s.formatted(:CONVERTED, 4).
|
440
|
-
s.formatted(:CONVERTED, 4).
|
441
|
-
s.formatted(:CONVERTED, 4).
|
442
|
-
s.formatted(:CONVERTED, 4).
|
439
|
+
expect(s.formatted(:CONVERTED, 4)).to include(" TEST1: [1, 2]")
|
440
|
+
expect(s.formatted(:CONVERTED, 4)).to include(" TEST2: 3456")
|
441
|
+
expect(s.formatted(:CONVERTED, 4)).to include(" TEST3")
|
442
|
+
expect(s.formatted(:CONVERTED, 4)).to include(" 00000000: 07 08 09 0A")
|
443
443
|
end
|
444
444
|
end
|
445
445
|
|
@@ -452,35 +452,35 @@ module Cosmos
|
|
452
452
|
s.write("test2", 0x0304)
|
453
453
|
s.append_item("test3", 32, :UINT)
|
454
454
|
s.write("test3", 0x05060708)
|
455
|
-
s.buffer.
|
455
|
+
expect(s.buffer).to eql "\x01\x02\x03\x04\x05\x06\x07\x08"
|
456
456
|
expect(s.buffer).to_not be s.buffer
|
457
457
|
expect(s.buffer(false)).to be s.buffer(false)
|
458
458
|
end
|
459
459
|
end
|
460
460
|
|
461
461
|
describe "buffer=" do
|
462
|
-
it "
|
462
|
+
it "complains if the given buffer is too small" do
|
463
463
|
s = Structure.new(:BIG_ENDIAN)
|
464
464
|
s.append_item("test1", 16, :UINT)
|
465
465
|
expect { s.buffer = "\x00" }.to raise_error(RuntimeError, "Buffer length less than defined length")
|
466
466
|
end
|
467
467
|
|
468
|
-
it "
|
468
|
+
it "complains if the given buffer is too big" do
|
469
469
|
s = Structure.new(:BIG_ENDIAN)
|
470
470
|
s.append_item("test1", 16, :UINT)
|
471
471
|
expect { s.buffer = "\x00\x00\x00" }.to raise_error(RuntimeError, "Buffer length greater than defined length")
|
472
472
|
end
|
473
473
|
|
474
|
-
it "
|
474
|
+
it "does not complain if the given buffer is too big and we're not fixed length" do
|
475
475
|
s = Structure.new(:BIG_ENDIAN)
|
476
476
|
s.append_item("test1", 8, :UINT)
|
477
477
|
s.append_item("test2", 0, :BLOCK)
|
478
478
|
s.buffer = "\x01\x02\x03"
|
479
|
-
s.read("test1").
|
480
|
-
s.read("test2").
|
479
|
+
expect(s.read("test1")).to eql 1
|
480
|
+
expect(s.read("test2")).to eql "\x02\x03"
|
481
481
|
end
|
482
482
|
|
483
|
-
it "
|
483
|
+
it "sets the buffer" do
|
484
484
|
s = Structure.new(:BIG_ENDIAN)
|
485
485
|
s.append_item("test1", 8, :UINT, 16)
|
486
486
|
s.write("test1", [1,2])
|
@@ -488,18 +488,18 @@ module Cosmos
|
|
488
488
|
s.write("test2", 0x0304)
|
489
489
|
s.append_item("test3", 32, :UINT)
|
490
490
|
s.write("test3", 0x05060708)
|
491
|
-
s.read("test1").
|
492
|
-
s.read("test2").
|
493
|
-
s.read("test3").
|
491
|
+
expect(s.read("test1")).to eql [1,2]
|
492
|
+
expect(s.read("test2")).to eql 0x0304
|
493
|
+
expect(s.read("test3")).to eql 0x05060708
|
494
494
|
s.buffer = "\x00\x01\x02\x03\x04\x05\x06\x07"
|
495
|
-
s.read("test1").
|
496
|
-
s.read("test2").
|
497
|
-
s.read("test3").
|
495
|
+
expect(s.read("test1")).to eql [0,1]
|
496
|
+
expect(s.read("test2")).to eql 0x0203
|
497
|
+
expect(s.read("test3")).to eql 0x04050607
|
498
498
|
end
|
499
499
|
end
|
500
500
|
|
501
501
|
describe "clone" do
|
502
|
-
it "
|
502
|
+
it "duplicates the structure with a new buffer" do
|
503
503
|
s = Structure.new(:BIG_ENDIAN)
|
504
504
|
s.append_item("test1", 8, :UINT, 16)
|
505
505
|
s.write("test1", [1,2])
|
@@ -517,33 +517,33 @@ module Cosmos
|
|
517
517
|
expect(s2.buffer(false)).to eql s.buffer(false)
|
518
518
|
# But not the same object
|
519
519
|
expect(s2.buffer(false)).to_not be s.buffer(false)
|
520
|
-
s2.read("test1").
|
521
|
-
s2.read("test2").
|
522
|
-
s2.read("test3").
|
520
|
+
expect(s2.read("test1")).to eql [1,2]
|
521
|
+
expect(s2.read("test2")).to eql 0x0304
|
522
|
+
expect(s2.read("test3")).to eql 0x05060708
|
523
523
|
s2.write("test1", [0,0])
|
524
|
-
s2.read("test1").
|
524
|
+
expect(s2.read("test1")).to eql [0,0]
|
525
525
|
# Ensure we didn't change the original
|
526
|
-
s.read("test1").
|
526
|
+
expect(s.read("test1")).to eql [1,2]
|
527
527
|
end
|
528
528
|
end
|
529
529
|
|
530
530
|
describe "enable_method_missing" do
|
531
|
-
it "
|
531
|
+
it "enables reading by name" do
|
532
532
|
s = Structure.new(:BIG_ENDIAN)
|
533
533
|
s.append_item("test1", 8, :UINT, 16)
|
534
534
|
s.write("test1", [1,2])
|
535
535
|
s.enable_method_missing
|
536
|
-
s.test1.
|
536
|
+
expect(s.test1).to eql [1,2]
|
537
537
|
end
|
538
538
|
|
539
|
-
it "
|
539
|
+
it "enables writing by name" do
|
540
540
|
s = Structure.new(:BIG_ENDIAN)
|
541
541
|
s.append_item("test1", 8, :UINT, 16)
|
542
542
|
s.write("test1", [1,2])
|
543
543
|
s.enable_method_missing
|
544
|
-
s.test1.
|
544
|
+
expect(s.test1).to eql [1,2]
|
545
545
|
s.test1 = [3,4]
|
546
|
-
s.test1.
|
546
|
+
expect(s.test1).to eql [3,4]
|
547
547
|
end
|
548
548
|
|
549
549
|
it "raises an exception if there is no buffer" do
|
@@ -553,7 +553,7 @@ module Cosmos
|
|
553
553
|
expect { s.test1 }.to raise_error(/No buffer/)
|
554
554
|
end
|
555
555
|
|
556
|
-
it "
|
556
|
+
it "complains if it can't find an item" do
|
557
557
|
s = Structure.new(:BIG_ENDIAN)
|
558
558
|
s.enable_method_missing
|
559
559
|
expect { s.test1 }.to raise_error(ArgumentError, "Unknown item: test1")
|