class TestToneGenerator
Constants
- ROOT
Public Instance Methods
setup()
click to toggle source
# File test/test_tone_generator.rb, line 13 def setup CW::Cfg.reset @tg = CW::ToneGenerator.new end
teardown()
click to toggle source
# File test/test_tone_generator.rb, line 18 def teardown @tg = nil end
test_assert()
click to toggle source
# File test/test_tone_generator.rb, line 22 def test_assert assert 1 end
test_code_filename()
click to toggle source
# File test/test_tone_generator.rb, line 30 def test_code_filename assert_equal File.join(ROOT, '.cw', 'audio', 'dot.wav'), @tg.code.filename(:dot) assert_equal File.join(ROOT, '.cw', 'audio', 'dash.wav'), @tg.code.filename(:dash) assert_equal File.join(ROOT, '.cw', 'audio', 'space.wav'), @tg.code.filename(:space) assert_equal File.join(ROOT, '.cw', 'audio', 'e_space.wav'), @tg.code.filename(:e_space) end
test_code_spb_for_15_wpm()
click to toggle source
# File test/test_tone_generator.rb, line 37 def test_code_spb_for_15_wpm CW::Cfg.config.params['wpm'] = 15 tg = CW::ToneGenerator.new element = 192 assert_equal element * 1, tg.code.spb(:dot) assert_equal element * 3, tg.code.spb(:dash) assert_equal element * 1, tg.code.spb(:space) assert_equal element * 1, tg.code.spb(:e_space) end
test_code_spb_for_20_wpm()
click to toggle source
# File test/test_tone_generator.rb, line 67 def test_code_spb_for_20_wpm CW::Cfg.config.params['wpm'] = 20 tg = CW::ToneGenerator.new element = 144 assert_equal element * 1, tg.code.spb(:dot) assert_equal element * 3, tg.code.spb(:dash) assert_equal element * 1, tg.code.spb(:space) assert_equal element * 1, tg.code.spb(:e_space) end
test_code_spb_for_25_wpm()
click to toggle source
# File test/test_tone_generator.rb, line 47 def test_code_spb_for_25_wpm CW::Cfg.config.params['wpm'] = 25 tg = CW::ToneGenerator.new element = 115 assert_equal element * 1, tg.code.spb(:dot) assert_equal element * 3, tg.code.spb(:dash) assert_equal element * 1, tg.code.spb(:space) assert_equal element * 1, tg.code.spb(:e_space) end
test_code_spb_for_40_wpm()
click to toggle source
# File test/test_tone_generator.rb, line 57 def test_code_spb_for_40_wpm CW::Cfg.config.params['wpm'] = 40 tg = CW::ToneGenerator.new element = 72 assert_equal element * 1, tg.code.spb(:dot) assert_equal element * 3, tg.code.spb(:dash) assert_equal element * 1, tg.code.spb(:space) assert_equal element * 1, tg.code.spb(:e_space) end
test_cw_encoding_fetch_returns_dot_dash_given_the_letter_a()
click to toggle source
# File test/test_tone_generator.rb, line 116 def test_cw_encoding_fetch_returns_dot_dash_given_the_letter_a assert_equal [:dot, :dash], @tg.cw_encoding.fetch('a') assert_equal [:dash, :dot], @tg.cw_encoding.fetch('n') end
test_cw_encoding_responds_to_fetch()
click to toggle source
# File test/test_tone_generator.rb, line 112 def test_cw_encoding_responds_to_fetch assert_equal(true, @tg.cw_encoding.respond_to?(:fetch)) end
test_cw_encoding_returns_a_cw_encoding_object()
click to toggle source
# File test/test_tone_generator.rb, line 108 def test_cw_encoding_returns_a_cw_encoding_object assert_equal CW::Encoding, @tg.cw_encoding.class end
test_elements()
click to toggle source
# File test/test_tone_generator.rb, line 77 def test_elements assert_equal :dot, @tg.elements.first assert_equal :dash, @tg.elements.fetch(1) assert_equal :space, @tg.elements.fetch(2) assert_equal :e_space, @tg.elements.last assert_equal 4, @tg.elements.size end
test_generate_samples()
click to toggle source
# File test/test_tone_generator.rb, line 85 def test_generate_samples CW::Cfg.config.params['wpm'] = 40 tg = CW::ToneGenerator.new samples = tg.generate_samples(:dot) assert_equal Array, samples.class assert_equal 72, samples.size assert_equal samples.size, tg.generate_samples(:space).size assert_equal samples.size * 3, tg.generate_samples(:dash).size end
test_play_filename()
click to toggle source
# File test/test_tone_generator.rb, line 104 def test_play_filename assert_equal File.join(ROOT, 'audio', 'audio_output.wav'), @tg.play_filename end
test_push_enc_does_something()
click to toggle source
# File test/test_tone_generator.rb, line 121 def test_push_enc_does_something # p @tg.push_enc([nil]).class # p @tg.push_enc(['a','b']) assert_equal 4, @tg.push_enc([nil]).size assert_equal 4, @tg.push_enc(['a']).size assert_equal 6, @tg.push_enc(['a','b']).size assert_equal 8, @tg.push_enc(['a','b','c']).size assert_equal 'a', @tg.push_enc(['a','b']).first assert_equal Hash, @tg.push_enc(['a','b']).fetch(1).class assert_equal 'b', @tg.push_enc(['a','b']).fetch(2) assert_equal Hash, @tg.push_enc(['a','b']).last.class assert_equal :space, @tg.push_enc(['a','b']).last[:name] = :space assert_equal 'b', @tg.push_enc(['a','b']).fetch(2) assert_equal Array, @tg.push_enc(['a','b']).class end
test_refute()
click to toggle source
# File test/test_tone_generator.rb, line 26 def test_refute refute nil end
test_space_or_espace_method_when_ewpm_active()
click to toggle source
# File test/test_tone_generator.rb, line 99 def test_space_or_espace_method_when_ewpm_active @tg.instance_variable_set :@effective_wpm, 10 assert_equal({ name: :e_space }, @tg.space_or_espace) end
test_space_or_espace_method_when_no_wpm_equals_ewpm()
click to toggle source
# File test/test_tone_generator.rb, line 95 def test_space_or_espace_method_when_no_wpm_equals_ewpm assert_equal({ name: :space }, @tg.space_or_espace) end
test_word_space_returns_space_if_not_ewpm()
click to toggle source
# File test/test_tone_generator.rb, line 137 def test_word_space_returns_space_if_not_ewpm # assert_equal '', @tg.word_space end