File: sequences_test.go

package info (click to toggle)
golang-github-konsorten-go-windows-terminal-sequences 1.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 72 kB
  • sloc: makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,164 bytes parent folder | download
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
// +build windows

package sequences

import (
	"fmt"
	"os"
	"syscall"
	"testing"
)

func TestStdoutSequencesOn(t *testing.T) {
	err := EnableVirtualTerminalProcessing(syscall.Stdout, true)
	if err != nil {
		t.Fatalf("Failed to enable VTP: %v", err)
	}
	defer EnableVirtualTerminalProcessing(syscall.Stdout, false)

	fmt.Fprintf(os.Stdout, "\x1b[34mHello \x1b[35mWorld\x1b[0m!\n")
}

func TestStdoutSequencesOff(t *testing.T) {
	err := EnableVirtualTerminalProcessing(syscall.Stdout, false)
	if err != nil {
		t.Fatalf("Failed to enable VTP: %v", err)
	}

	fmt.Fprintf(os.Stdout, "\x1b[34mHello \x1b[35mWorld\x1b[0m!\n")
}

func TestStderrSequencesOn(t *testing.T) {
	err := EnableVirtualTerminalProcessing(syscall.Stderr, true)
	if err != nil {
		t.Fatalf("Failed to enable VTP: %v", err)
	}
	defer EnableVirtualTerminalProcessing(syscall.Stderr, false)

	fmt.Fprintf(os.Stderr, "\x1b[34mHello \x1b[35mWorld\x1b[0m!\n")
}

func TestStderrSequencesOff(t *testing.T) {
	err := EnableVirtualTerminalProcessing(syscall.Stderr, false)
	if err != nil {
		t.Fatalf("Failed to enable VTP: %v", err)
	}

	fmt.Fprintf(os.Stderr, "\x1b[34mHello \x1b[35mWorld\x1b[0m!\n")
}