Class: TestTiming

Inherits:
MiniTest::Test
  • Object
show all
Defined in:
/Users/martyn/cw/cw_clone/test/test_timing.rb

Constant Summary

ROOT =
File.expand_path File.dirname(__FILE__) + '/../'

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



13
14
15
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 13

def setup
  @timing = CWG::Timing.new
end

- (Object) teardown



17
18
19
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 17

def teardown
  @timing = nil
end

- (Object) test_append_char_delay_for_i_with_ewpm



213
214
215
216
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 213

def test_append_char_delay_for_i_with_ewpm
  @timing.append_char_delay('i', 20, 10)
  assert_equal(( 2 * 0.06) + (1 * 0.06) + (3 * 0.12), @timing.delay_time)
end

- (Object) test_append_char_delay_for_m_with_ewpm



218
219
220
221
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 218

def test_append_char_delay_for_m_with_ewpm
  @timing.append_char_delay('m', 20, 10)
  assert_equal((2 * 0.18) + (1 * 0.06) + (3 * 0.12), @timing.delay_time)
end

- (Object) test_append_char_delay_no_ewpm



207
208
209
210
211
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 207

def test_append_char_delay_no_ewpm
  assert_equal(0, @timing.delay_time)
  @timing.append_char_delay('m', 20, nil)
  assert_equal( (( 2 * 0.18)) + (4 * 0.06), @timing.delay_time)
end

- (Object) test_attr_accessor_delay_time



21
22
23
24
25
26
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 21

def test_attr_accessor_delay_time
  @timing.delay_time = 10
  assert_equal 10, @timing.delay_time
  @timing.delay_time = '10'
  assert_equal '10', @timing.delay_time
end

- (Object) test_attr_accessor_start_time



28
29
30
31
32
33
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 28

def test_attr_accessor_start_time
  @timing.start_time = 20
  assert_equal 20, @timing.start_time
  @timing.start_time = "text"
  assert_equal "text", @timing.start_time
end

- (Object) test_char_delay_for_letter_e



167
168
169
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 167

def test_char_delay_for_letter_e
  assert_equal(0.06 + (3 * 0.06), @timing.char_delay('e', 20, nil))
end

- (Object) test_char_delay_for_letter_e_with_ewpm



191
192
193
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 191

def test_char_delay_for_letter_e_with_ewpm
  assert_equal(0.06 + (3 * 0.12), @timing.char_delay('e', 20, 10))
end

- (Object) test_char_delay_for_letter_i



175
176
177
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 175

def test_char_delay_for_letter_i
  assert_equal( (( 2 * 0.06)) + (4 * 0.06), @timing.char_delay('i', 20, nil))
end

- (Object) test_char_delay_for_letter_m



179
180
181
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 179

def test_char_delay_for_letter_m
  assert_equal( (( 2 * 0.18)) + (4 * 0.06), @timing.char_delay('m', 20, nil))
end

- (Object) test_char_delay_for_letter_t



171
172
173
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 171

def test_char_delay_for_letter_t
  assert_equal((0.06 * 3) + (3 * 0.06), @timing.char_delay('t', 20, nil))
end

- (Object) test_char_delay_for_letter_t_with_ewpm



195
196
197
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 195

def test_char_delay_for_letter_t_with_ewpm
  assert_equal((3 * 0.06) + (3 * 0.12), @timing.char_delay('t', 20, 10))
end

- (Object) test_char_delay_for_number_0



187
188
189
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 187

def test_char_delay_for_number_0
  assert_equal( (( 5 * 0.18)) + (7 * 0.06), @timing.char_delay('0', 20, nil))
end

- (Object) test_char_delay_for_number_0_with_ewpm



203
204
205
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 203

def test_char_delay_for_number_0_with_ewpm
  assert_equal( ((5 * 0.18) + (4 * 0.06)) + (3 * 0.12), @timing.char_delay('0', 20, 10))
end

- (Object) test_char_delay_for_number_5



183
184
185
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 183

def test_char_delay_for_number_5
  assert_equal( (( 5 * 0.06)) + (7 * 0.06), @timing.char_delay('5', 20, nil))
end

- (Object) test_char_delay_for_number_5_with_ewpm



199
200
201
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 199

def test_char_delay_for_number_5_with_ewpm
  assert_equal( ((5 * 0.06) + (4 * 0.06)) + (3 * 0.12), @timing.char_delay('5', 20, 10))
end

- (Object) test_char_delay_timeout



118
119
120
121
122
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 118

def test_char_delay_timeout
  @timing.start_time = Time.now
  @timing.delay_time = - 1.0
  assert_equal true, @timing.char_delay_timeout?
end

- (Object) test_char_delay_timeout_2



124
125
126
127
128
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 124

def test_char_delay_timeout_2
  @timing.start_time = Time.now
  @timing.delay_time = + 1.0
  assert_equal false, @timing.char_delay_timeout?
end

- (Object) test_char_timing_for_dash



135
136
137
138
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 135

def test_char_timing_for_dash
  @timing.instance_variable_set(:@wpm, 20)
  assert_equal 0.18 + (0.06 * 3), @timing.char_timing([:dash])
end

- (Object) test_char_timing_for_dash_dot



140
141
142
143
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 140

def test_char_timing_for_dash_dot
  @timing.instance_variable_set(:@wpm, 120)
  assert_equal 0.03 + 0.01 + (0.01 * 3) + (0.01 * 1), @timing.char_timing([:dash, :dot])
end

- (Object) test_char_timing_for_dot



130
131
132
133
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 130

def test_char_timing_for_dot
  @timing.instance_variable_set(:@wpm, 20)
  assert_equal 0.06 + (0.06 * 3), @timing.char_timing([:dot])
end

- (Object) test_code_space_timing_with_ewpm



150
151
152
153
154
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 150

def test_code_space_timing_with_ewpm
  @timing.instance_variable_set(:@wpm, 20)
  @timing.instance_variable_set(:@effective_wpm, 10)
  assert_equal (0.12 * 3), @timing.code_space_timing
end

- (Object) test_code_space_timing_with_no_ewpm



145
146
147
148
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 145

def test_code_space_timing_with_no_ewpm
  @timing.instance_variable_set(:@wpm, 20)
  assert_equal (0.06 * 3), @timing.code_space_timing
end

- (Object) test_cw_encoding_returns_an_encoding



43
44
45
46
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 43

def test_cw_encoding_returns_an_encoding
  assert_equal [:dot, :dash], @timing.cw_encoding('a')
  assert_equal [:dash,:dash,:dot,:dot], @timing.cw_encoding('z')
end

- (Object) test_dot_ms_returns_correct_ms_for_wpm



52
53
54
55
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 52

def test_dot_ms_returns_correct_ms_for_wpm
  @timing.instance_variable_set(:@wpm, 20)
  assert_equal 0.06, @timing.dot_ms
end

- (Object) test_dot_returns_correct_wpm_timing_for_a_dot



48
49
50
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 48

def test_dot_returns_correct_wpm_timing_for_a_dot
  assert_equal 0.06, @timing.dot(20)
end

- (Object) test_effective_dot_ms



99
100
101
102
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 99

def test_effective_dot_ms
  @timing.instance_variable_set(:@effective_wpm, 20)
  assert_equal 0.06, @timing.effective_dot_ms
end

- (Object) test_init_char_timer



104
105
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 104

def test_init_char_timer
end

- (Object) test_init_char_timer_sets_delay_time



113
114
115
116
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 113

def test_init_char_timer_sets_delay_time
  @timing.init_char_timer
  assert_equal 0.0, @timing.delay_time
end

- (Object) test_init_char_timer_sets_start_time



107
108
109
110
111
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 107

def test_init_char_timer_sets_start_time
  time_now = Time.now
  @timing.init_char_timer
  assert_in_delta time_now.to_i, @timing.start_time.to_i, 1
end

- (Object) test_init_play_words_timeout_sets_delay_play_time



85
86
87
88
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 85

def test_init_play_words_timeout_sets_delay_play_time
  @timing.init_play_words_timeout
  assert_equal 2.0, @timing.instance_variable_get(:@delay_play_time)
end

- (Object) test_init_play_words_timeout_sets_start_play_time



78
79
80
81
82
83
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 78

def test_init_play_words_timeout_sets_start_play_time
  time_now = Time.now
  @timing.init_play_words_timeout
  start_time = @timing.instance_variable_get(:@start_play_time)
  assert_in_delta time_now.to_i, start_time.to_i, 1
end

- (Object) test_init_print_words_timeout_sets_delay_print_time



64
65
66
67
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 64

def test_init_print_words_timeout_sets_delay_print_time
  @timing.init_print_words_timeout
  assert_equal 2.0, @timing.instance_variable_get(:@delay_print_time)
end

- (Object) test_init_print_words_timeout_sets_start_print_time



57
58
59
60
61
62
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 57

def test_init_print_words_timeout_sets_start_print_time
  time_now = Time.now
  @timing.init_print_words_timeout
  start_time = @timing.instance_variable_get(:@start_print_time)
  assert_in_delta time_now.to_i, start_time.to_i, 1
end

- (Object) test_initialize_initializes_delay_time



35
36
37
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 35

def test_initialize_initializes_delay_time
  assert_equal 0.0, @timing.delay_time
end

- (Object) test_initialize_initializes_instance_of_CwEncoding



39
40
41
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 39

def test_initialize_initializes_instance_of_CwEncoding
  assert_equal CWG::CwEncoding, @timing.instance_variable_get(:@cw_encoding).class
end

- (Object) test_play_words_timeout



90
91
92
93
94
95
96
97
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 90

def test_play_words_timeout
  @timing.instance_variable_set(:@start_play_time, Time.now)
  @timing.instance_variable_set(:@delay_play_time, 1)
  assert_equal false, @timing.play_words_timeout?
  @timing.instance_variable_set(:@start_play_time, Time.now - 2)
  @timing.instance_variable_set(:@delay_play_time, 1)
  assert_equal true, @timing.play_words_timeout?
end

- (Object) test_print_words_timeout



69
70
71
72
73
74
75
76
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 69

def test_print_words_timeout
  @timing.instance_variable_set(:@start_print_time, Time.now)
  @timing.instance_variable_set(:@delay_print_time, 2.0)
  assert_equal false, @timing.print_words_timeout?
  @timing.instance_variable_set(:@start_print_time, Time.now - 3)
  @timing.instance_variable_set(:@delay_print_time, 2.0)
  assert_equal true, @timing.print_words_timeout?
end

- (Object) test_space_timing_with_no_wpm



156
157
158
159
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 156

def test_space_timing_with_no_wpm
  @timing.instance_variable_set(:@wpm, 20)
  assert_equal (0.06 * 4), @timing.space_timing
end

- (Object) test_space_timing_with_wpm



161
162
163
164
165
# File '/Users/martyn/cw/cw_clone/test/test_timing.rb', line 161

def test_space_timing_with_wpm
  @timing.instance_variable_set(:@wpm, 20)
  @timing.instance_variable_set(:@effective_wpm, 10)
  assert_equal (0.12 * 4), @timing.space_timing
end