pkg.re/essentialkaos/ek@v12.36.0+incompatible/terminal/window/size_test.go (about)

     1  package window
     2  
     3  // ////////////////////////////////////////////////////////////////////////////////// //
     4  //                                                                                    //
     5  //                         Copyright (c) 2021 ESSENTIAL KAOS                          //
     6  //      Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>     //
     7  //                                                                                    //
     8  // ////////////////////////////////////////////////////////////////////////////////// //
     9  
    10  import (
    11  	"testing"
    12  
    13  	. "pkg.re/essentialkaos/check.v1"
    14  )
    15  
    16  // ////////////////////////////////////////////////////////////////////////////////// //
    17  
    18  func Test(t *testing.T) { TestingT(t) }
    19  
    20  type WindowSuite struct{}
    21  
    22  // ////////////////////////////////////////////////////////////////////////////////// //
    23  
    24  var _ = Suite(&WindowSuite{})
    25  
    26  // ////////////////////////////////////////////////////////////////////////////////// //
    27  
    28  func (s *WindowSuite) TestGetSize(c *C) {
    29  	w, h := GetSize()
    30  
    31  	c.Assert(w, Not(Equals), -1)
    32  	c.Assert(w, Not(Equals), 0)
    33  	c.Assert(h, Not(Equals), -1)
    34  	c.Assert(h, Not(Equals), 0)
    35  }
    36  
    37  func (s *WindowSuite) TestGetWidth(c *C) {
    38  	c.Assert(GetWidth(), Not(Equals), -1)
    39  	c.Assert(GetWidth(), Not(Equals), 0)
    40  }
    41  
    42  func (s *WindowSuite) TestGetHeight(c *C) {
    43  	c.Assert(GetHeight(), Not(Equals), -1)
    44  	c.Assert(GetHeight(), Not(Equals), 0)
    45  }
    46  
    47  func (s *WindowSuite) TestErrors(c *C) {
    48  	tty = "/non-exist"
    49  
    50  	w, h := GetSize()
    51  
    52  	c.Assert(w, Equals, -1)
    53  	c.Assert(h, Equals, -1)
    54  
    55  	tty = "/dev/tty"
    56  }