/usr/share/gocode/src/github.com/juju/ansiterm/context_test.go is in golang-github-juju-ansiterm-dev 0.0~git20161107.35c59b9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | // Copyright 2016 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package ansiterm
import (
"bytes"
gc "gopkg.in/check.v1"
)
type contextSuite struct{}
var _ = gc.Suite(&contextSuite{})
func (*contextSuite) newWriter() (*bytes.Buffer, *Writer) {
buff := &bytes.Buffer{}
writer := NewWriter(buff)
writer.noColor = false
return buff, writer
}
func (*contextSuite) TestBlank(c *gc.C) {
var context Context
c.Assert(context.sgr(), gc.Equals, "")
}
func (*contextSuite) TestAllUnknown(c *gc.C) {
context := Context{
Foreground: 123,
Background: 432,
Styles: []Style{456, 99},
}
c.Assert(context.sgr(), gc.Equals, "")
}
func (*contextSuite) TestForeground(c *gc.C) {
context := Foreground(Yellow)
c.Assert(context.sgr(), gc.Equals, "\x1b[33m")
}
func (*contextSuite) TestBackground(c *gc.C) {
context := Background(Blue)
c.Assert(context.sgr(), gc.Equals, "\x1b[44m")
}
func (*contextSuite) TestStyles(c *gc.C) {
context := Styles(Bold, Italic)
c.Assert(context.sgr(), gc.Equals, "\x1b[1;3m")
}
func (*contextSuite) TestValid(c *gc.C) {
context := Context{
Foreground: Yellow,
Background: Blue,
Styles: []Style{Bold, Italic},
}
c.Assert(context.sgr(), gc.Equals, "\x1b[1;3;33;44m")
}
func (*contextSuite) TestSetForeground(c *gc.C) {
var context Context
context.SetForeground(Yellow)
c.Assert(context.sgr(), gc.Equals, "\x1b[33m")
}
func (*contextSuite) TestSetBackground(c *gc.C) {
var context Context
context.SetBackground(Blue)
c.Assert(context.sgr(), gc.Equals, "\x1b[44m")
}
func (*contextSuite) TestSetStyles(c *gc.C) {
var context Context
context.SetStyle(Bold, Italic)
c.Assert(context.sgr(), gc.Equals, "\x1b[1;3m")
}
func (s *contextSuite) TestFprintfNoColor(c *gc.C) {
buff, writer := s.newWriter()
writer.noColor = true
context := Context{
Foreground: Yellow,
Background: Blue,
Styles: []Style{Bold, Italic},
}
context.Fprintf(writer, "hello %s, %d", "world", 42)
c.Assert(buff.String(), gc.Equals, "hello world, 42")
}
func (s *contextSuite) TestFprintfColor(c *gc.C) {
buff, writer := s.newWriter()
context := Context{
Foreground: Yellow,
Background: Blue,
Styles: []Style{Bold, Italic},
}
context.Fprintf(writer, "hello %s, %d", "world", 42)
c.Assert(buff.String(), gc.Equals, "\x1b[1;3;33;44mhello world, 42\x1b[0m")
}
|