Sha256: 6759ae8b2d1b43860328d3b1d68a3584976e7cb5870209cba0f45977386bfb6c

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require_relative '../../lib/trepanning.rb'

# Test Trepan::CmdProcessor
class TestSubCmdHelp < Test::Unit::TestCase

  def setup
    @dbg     = Trepan.new
    @core    = Trepan::Core.new(@dbg)
    @cmdproc = @core.processor = Trepan::CmdProcessor.new(@core)
    @cmds    = @cmdproc.instance_variable_get('@commands')
  end

  # See that subcommand class constants exist.
  def test_required_class_constants
    @cmds.each do |cmd_name, cmd|
      if cmd.is_a?(Trepan::SubcommandMgr)
        cmd.subcmds.subcmds.each do |subcmd_name, subcmd|
          where = "of subcommand #{subcmd_name} in command #{cmd_name}"
          %w(HELP NAME SHORT_HELP).each do
            |const|
            value = subcmd.my_const(const)
            assert_equal(true, value.is_a?(String),
                         "#{const} #{where} should be a String; got #{value}.")
          end
          value = subcmd.my_const('MIN_ABBREV')
          assert(value.is_a?(Fixnum),
                 "MIN_ABBREV #{where} should be a Fixnum; got #{value}.")

          if 'show' == cmd_name
            short_help = subcmd.my_const('SHORT_HELP')
            needed_start = 'Show '
            assert_equal(needed_start, short_help[0..needed_start.size-1],
                         "Short help #{where} should start: \"#{needed_start}\"; got #{short_help}")
          end
        end
      end
    end
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trepanning-2.15.35 test/unit/test-subcmd-help.rb
trepanning-2.15.33 test/unit/test-subcmd-help.rb