import ( . "gopkg.in/check.v1" ) // Test suite for the math package type MathSuite struct {} var _ = Suite(&MathSuite{}) // Test case for addition func (suite *MathSuite) TestAddition(c *C) { result := add(2, 3) c.Assert(result, Equals, 5) } // Test case for subtraction func (suite *MathSuite) TestSubtraction(c *C) { result := sub(5, 3) c.Assert(result, Equals, 2) } // Test case for division func (suite *MathSuite) TestDivision(c *C) { _, err := div(2, 0) c.Assert(err, NotNil) c.Fatalf("Division by zero is not allowed") }
import ( . "gopkg.in/check.v1" ) // Test suite for the string package type StringSuite struct {} var _ = Suite(&StringSuite{}) // Test case for concatenation func (suite *StringSuite) TestConcatenation(c *C) { result := concat("Hello", "World") c.Assert(result, Equals, "Hello World") } // Test case for invalid input func (suite *StringSuite) TestInput(c *C) { _, err := concat("", "World") c.Assert(err, NotNil) c.Fatalf("Cannot concatenate empty string") }In this example, the TestInput() function uses Fatalf() to log an error message and terminate the test if the function being tested returns an error due to invalid input (an empty string). Therefore, the gopkg.in.check.v1 package library is a testing framework for Go which provides functions and tools for writing and running tests in an organized way. The Fatalf() function is commonly used within the framework to log error messages and terminate tests immediately.