File: test_key_event_record.rb

package info (click to toggle)
ruby3.3 3.3.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 153,620 kB
  • sloc: ruby: 1,244,308; ansic: 836,474; yacc: 28,074; pascal: 6,748; sh: 3,913; python: 1,719; cpp: 1,158; makefile: 742; asm: 712; javascript: 394; lisp: 97; perl: 62; awk: 36; sed: 23; xml: 4
file content (41 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require_relative '../helper'
return unless Reline.const_defined?(:Windows)

class Reline::Windows
  class KeyEventRecord::Test < Reline::TestCase

    def setup
      # Ctrl+A
      @key = Reline::Windows::KeyEventRecord.new(0x41, 1, Reline::Windows::LEFT_CTRL_PRESSED)
    end

    def test_matches__with_no_arguments_raises_error
      assert_raise(ArgumentError) { @key.matches? }
    end

    def test_matches_char_code
      assert @key.matches?(char_code: 0x1)
    end

    def test_matches_virtual_key_code
      assert @key.matches?(virtual_key_code: 0x41)
    end

    def test_matches_control_keys
      assert @key.matches?(control_keys: :CTRL)
    end

    def test_doesnt_match_alt
      refute @key.matches?(control_keys: :ALT)
    end

    def test_doesnt_match_empty_control_key
      refute @key.matches?(control_keys: [])
    end

    def test_matches_control_keys_and_virtual_key_code
      assert @key.matches?(control_keys: :CTRL, virtual_key_code: 0x41)
    end

  end
end