Commit b729f263 authored by Felix Kollmann's avatar Felix Kollmann
Browse files

Fixed return code handling

Limited build to windows, only
parent d0a95e57
// +build windows
package sequences
import (
......@@ -26,7 +28,7 @@ func EnableVirtualTerminalProcessing(stream syscall.Handle, enable bool) error {
}
ret, _, err := setConsoleMode.Call(uintptr(unsafe.Pointer(stream)), uintptr(mode))
if ret != 0 {
if ret == 0 {
return err
}
......
// +build windows
package sequences
import (
......@@ -7,28 +9,40 @@ import (
"testing"
)
func TestStdoutSequencesOn(T *testing.T) {
EnableVirtualTerminalProcessing(syscall.Stdout, true)
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) {
EnableVirtualTerminalProcessing(syscall.Stdout, false)
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) {
EnableVirtualTerminalProcessing(syscall.Stderr, true)
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) {
EnableVirtualTerminalProcessing(syscall.Stderr, false)
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")
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment