Sha256: 72cb60d9acd3874b7b35cd4ff59517cd6773eada34a347fd902d36da0e86a2f7

Contents?: true

Size: 1.43 KB

Versions: 11

Compression:

Stored size: 1.43 KB

Contents

# include Test::Unit::Assertions
class IFD_Assertion
  # Assert 2 values
  def self.reg_compare sActual, regValue, isSpecialChar=false
    begin
      if !isSpecialChar
        sActual = sActual.strip
        regValue = regValue.strip.gsub("[", "\\[").gsub("]", "\\]").gsub("(", "\\(").gsub(")", "\\)").gsub(">", "\\>")
      end
    rescue StandardError => myStandardError
      put_log "\n>>> Error: #{myStandardError}"
    end

    # put_log "\nsActual:#{sActual}, regValue:#{regValue}"
    if ((sActual.nil? and regValue.nil?) or (!sActual.nil? and sActual.empty? and !regValue.nil? and regValue.empty?))
      return true
    end

    if ((sActual.nil? and !regValue.nil?) or (!sActual.nil? and regValue.nil?))
      return false
    end

    if (!sActual.nil? and !sActual.empty?)
      sCookActual = sActual.gsub(/\n|\r/, " ")
      if (sCookActual == regValue or (isSpecialChar and sCookActual.include? regValue) or (!isSpecialChar and sCookActual =~ /^.*#{regValue}.*$/))
        return true
      end
    end

    return false
  end

  def self.assert_string_contain(expected, actual)
    unless (actual.to_s).include? (expected.to_s)
      raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
    end
  end

  def self.assert_string_equal(expected, actual)
    if expected.to_s != actual.to_s
      raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
Ifd_Mobile-1.4.0 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-1.3.0 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-1.2.0 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-1.1.0 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-1.0.0 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.9 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.8 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.6 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.5 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.1 lib/Ifd_Mobile/methods/IFD_Assertion.rb
Ifd_Mobile-0.1.0 lib/Ifd_Mobile/methods/IFD_Assertion.rb