func TestSort(t *testing.T) { c := check.New(t) input := []int{3, 2, 1} expected := []int{1, 2, 3} result := sort(input) c.Assert(result, check.DeepEquals, expected) }
func TestReadFromFile(t *testing.T) { c := check.New(t) filename := "testdata/testfile.txt" result, err := readFromFile(filename) c.Assert(err, check.IsNil) c.Assert(result, check.Equals, "Hello, world!") }In this example, a test function called TestReadFromFile is defined, which creates a new instance of the check.C struct using the check.New function. The filename for the test data is defined, and the readFromFile function is called to generate a result and an error. The assertion functions c.Assert are used to check that the error object is nil (indicating success), and that the result string matches the expected output.