Sha256: 1d278e78dac0a1b3476f379e0984b0cbbbb9b6d531a8815c5956beaf6e158d0c

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

###########################################################
# tc_sunos.rb
#
# Test suite for sys-cpu on Solaris. This should be run
# via the 'rake test' task.
###########################################################
require "sys/cpu"
require "test/unit"
require "tc_version"
include Sys

class TC_SunOS < Test::Unit::TestCase
   def test_cpu_freq
      assert_respond_to(CPU, :freq)
      assert_nothing_raised{ CPU.freq }
      assert_nothing_raised{ CPU.freq(0) }
      assert_kind_of(Integer, CPU.freq(0))
   end

   def test_cpu_type
      assert_respond_to(CPU, :cpu_type)
      assert_nothing_raised{ CPU.cpu_type }
      assert_kind_of(String, CPU.cpu_type)
   end

   def test_fpu_type
      assert_respond_to(CPU, :fpu_type)
      assert_nothing_raised{ CPU.fpu_type }
      assert_kind_of(String, CPU.fpu_type)
   end

   def test_load_avg
      assert_respond_to(CPU, :load_avg)
      assert_nothing_raised{ CPU.load_avg }
      assert_kind_of(Array, CPU.load_avg)
      assert_equal(3, CPU.load_avg.length)
      assert_kind_of(Float, CPU.load_avg.first)
   end

   def test_cpu_model
      assert_respond_to(CPU, :model)
      assert_nothing_raised{ CPU.model }
      assert_kind_of(String, CPU.model)
   end

   def test_num_cpu
      assert_respond_to(CPU, :num_cpu)
      assert_nothing_raised{ CPU.num_cpu }
      assert_kind_of(Integer, CPU.num_cpu)
   end

   def test_state
      assert_respond_to(CPU, :state)
      assert_nothing_raised{ CPU.state }
      assert_nothing_raised{ CPU.state(0) }
      assert_kind_of(String, CPU.state(0))
   end

   def test_exceptions
      assert_raises(Sys::CPU::Error){ CPU.state(55) }
      assert_raises(TypeError){ CPU.state("yo") }
      assert_raises(Sys::CPU::Error){ CPU.freq(999) }
      assert_raises(TypeError){ CPU.freq("yo") }
   end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sys-cpu-0.6.0-mswin32 test/tc_sunos.rb
sys-cpu-0.6.1-x86-mswin32-60 test/tc_sunos.rb