Test functions should provide comprehensive coverage of both expected and edge cases. Include tests for: 1. **Boundary conditions**: Test zero, minimum, maximum values, and other special cases.
Test functions should provide comprehensive coverage of both expected and edge cases. Include tests for:
func TestTemperature(t *testing.T) {
// Test normal case
logits, err := Temperature(0.5).Apply([]float64{-3, -2, -1, 0, 1, 2, 4})
if err != nil {
t.Error(err)
}
// Test boundary case (zero)
logits, err = Temperature(0).Apply([]float64{-3, -2, -1, 0, 1, 2, 4})
if err != nil {
t.Error(err)
}
}
// Test with unsorted inputs
logits, err := Temperature(0.5).Apply([]float64{2, -1, 4, -3, 1, -2, 0})
// Don't just test ParseToolCalls, but also intermediate steps
func TestFindTemplatePrefix(t *testing.T) { /* ... */ }
func TestExtractToolTokens(t *testing.T) { /* ... */ }
func TestParseToolCalls(t *testing.T) { /* ... */ }
tests := []struct {
name string
input string
valid bool
want Result
wantErr error
}{
{
name: "valid input",
input: "valid data",
valid: true,
want: expectedResult,
},
{
name: "invalid input",
input: "invalid data",
valid: false,
wantErr: ErrInvalidData,
},
}
Thorough test coverage helps catch edge cases and ensures code robustness, particularly for functionality that may be used across different parts of the system.
Enter the URL of a public GitHub repository