SelectionTests.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // File.swift
  3. //
  4. //
  5. // Created by Miguel de Icaza on 4/29/20.
  6. //
  7. import Foundation
  8. import XCTest
  9. @testable import SwiftTerm
  10. final class SelectionTests: XCTestCase, TerminalDelegate {
  11. func send(source: Terminal, data: ArraySlice<UInt8>) {
  12. print ("here")
  13. }
  14. func testDoesNotCrashWhenSelectingWordOrExpressionOutsideColumnRange ()
  15. {
  16. let terminal = Terminal(delegate: self, options: TerminalOptions (cols: 10, rows: 10))
  17. let selection = SelectionService(terminal: terminal)
  18. terminal.feed (text: "1234567890")
  19. // depending on the size of terminal view, there might be a space near the margin where the user
  20. // clicks which might result in a col or row outside the bounds of terminal,
  21. selection.selectWordOrExpression(at: Position(col: -1, row: 0), in: terminal.buffer)
  22. selection.selectWordOrExpression(at: Position(col: 11, row: 0), in: terminal.buffer)
  23. }
  24. func testDoesNotCrashWhenSelectingWordOrExpressionOutsideRowRange ()
  25. {
  26. let terminal = Terminal(delegate: self, options: TerminalOptions (cols: 10, rows: 10))
  27. let selection = SelectionService(terminal: terminal)
  28. terminal.feed (text: "1234567890")
  29. // depending on the size of terminal view, there might be a space near the margin where the user
  30. // clicks which might result in a col or row outside the bounds of terminal,
  31. selection.selectWordOrExpression(at: Position (col: 0, row: -1), in: terminal.buffer)
  32. }
  33. }