tighten up Hub and add comments
[god.git] / test / test_system_process.rb
blobb62786a9c3bf94541095ee1802fa1085724c5ac7
1 require File.dirname(__FILE__) + '/helper'
3 class TestSystemProcess < Test::Unit::TestCase
4   def setup
5     pid = Process.pid
6     @process = System::Process.new(pid)
7   end
8   
9   def test_exists_should_return_true_for_running_process
10     assert_equal true, @process.exists?
11   end
12   
13   def test_exists_should_return_false_for_non_existant_process
14     assert_equal false, System::Process.new(9999999).exists?
15   end
16   
17   def test_memory
18     assert_kind_of Integer, @process.memory
19     assert @process.memory > 0
20   end
21   
22   def test_percent_memory
23     assert_kind_of Float, @process.percent_memory
24   end
25   
26   def test_percent_cpu
27     assert_kind_of Float, @process.percent_cpu
28   end
29   
30   def test_cpu_time
31     assert_kind_of Integer, @process.cpu_time
32   end
33   
34   def test_time_string_to_seconds
35     assert_equal 0, @process.bypass.time_string_to_seconds('0:00:00')
36     assert_equal 0, @process.bypass.time_string_to_seconds('0:00:55')
37     assert_equal 27, @process.bypass.time_string_to_seconds('0:27:32')
38     assert_equal 75, @process.bypass.time_string_to_seconds('1:15:13')
39     assert_equal 735, @process.bypass.time_string_to_seconds('12:15:13')
40   end
41 end