Sha256: f91f92101b1200ed4beb5a1ba09f71418b381f22d188747b3adb62be226aa7cb

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

require 'spec_helper'
require 'cosmos/conversions/generic_conversion'

module Cosmos

  describe GenericConversion do

    describe "initialize" do
      it "should take code_to_eval, converted_type and converted_bit_size" do
        gc = GenericConversion.new("10 / 2",:UINT,8)
        gc.code_to_eval.should eql "10 / 2"
        gc.converted_type.should eql :UINT
        gc.converted_bit_size.should eql 8
      end

      it "should complain about invalid converted_type" do
        expect { GenericConversion.new("",:MINE,8) }.to raise_error("Invalid type MINE")
      end
    end

    describe "call" do
      it "should call the code to eval and return the result" do
        gc = GenericConversion.new("10 / 2",:UINT,8)
        gc.call(0,0,0).should eql 5
      end
    end

    describe "to_s" do
      it "should return the code to eval" do
        GenericConversion.new("10 / 2").to_s.should eql "10 / 2"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cosmos-3.2.1 spec/conversions/generic_conversion_spec.rb
cosmos-3.2.0 spec/conversions/generic_conversion_spec.rb
cosmos-3.1.2 spec/conversions/generic_conversion_spec.rb
cosmos-3.1.1 spec/conversions/generic_conversion_spec.rb
cosmos-3.1.0 spec/conversions/generic_conversion_spec.rb