github.com/dancsecs/gotomd@v0.0.0-20240310162206-65c4805cf510/example1/example1_test.go (about)

     1  package example1_test
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/dancsecs/gotomd/example1"
     8  	"github.com/dancsecs/sztest"
     9  )
    10  
    11  func Test_PASS_Example1(t *testing.T) {
    12  	chk := sztest.CaptureNothing(t)
    13  	defer chk.Release()
    14  
    15  	chk.Int(example1.TimesTwo(2), 4)
    16  	chk.Int(example1.TimesThree(222222222), 666666666)
    17  
    18  	structure := new(example1.StructureType)
    19  	structure.F1 = "Total: "
    20  	chk.Str(structure.GetF1(1, 2, 3), "Total: 6")
    21  }
    22  
    23  func Test_FAIL_Example1(t *testing.T) {
    24  	chk := sztest.CaptureStdout(t)
    25  	defer chk.Release()
    26  
    27  	chk.FailFast(false) // Run all tests before exiting function.
    28  
    29  	chk.Int(example1.TimesTwo(2), 5, "2+2=5 (is true for big values of two)")
    30  	chk.Str(
    31  		"New in Got"+" Similar in (1) both",
    32  		" Similar in (2) both"+", new in Wnt",
    33  	)
    34  
    35  	fmt.Println("This output line will be different")
    36  	chk.Stdout("This output line is different")
    37  
    38  	structure := new(example1.StructureType)
    39  	structure.F1 = "Total: "
    40  	chk.Str(structure.GetF1(1, 2, 3), "Sum: 6")
    41  }