github.com/moontrade/mdbx-go@v0.4.0/internal/capture/capture_testwrapper.go (about) 1 package capture 2 3 /* 4 #include <stdio.h> 5 void printSomething() { 6 printf("C\n"); 7 } 8 */ 9 import "C" 10 11 import ( 12 "fmt" 13 "testing" 14 15 "github.com/stretchr/testify/assert" 16 ) 17 18 func testCapture(t *testing.T) { 19 out, err := Capture(func() { 20 fmt.Println("Go") 21 C.printSomething() 22 }) 23 assert.NoError(t, err) 24 25 assert.Contains(t, string(out), "Go") 26 assert.NotContains(t, string(out), "C") 27 } 28 29 func testCaptureWithCGo(t *testing.T) { 30 out, err := CaptureWithCGo(func() { 31 fmt.Println("Go") 32 C.printSomething() 33 }) 34 assert.NoError(t, err) 35 36 assert.Contains(t, string(out), "Go") 37 assert.Contains(t, string(out), "C") 38 }