Skip to content

Instantly share code, notes, and snippets.

@mitchallen
Created March 22, 2022 02:45
Show Gist options
  • Save mitchallen/fd6a5dec9b981f9e58f40c77cc063236 to your computer and use it in GitHub Desktop.
Save mitchallen/fd6a5dec9b981f9e58f40c77cc063236 to your computer and use it in GitHub Desktop.
go-lib test file
/**
* Author: Mitch Allen
* File: go-lib_test.go
*/
package lib
import (
"testing"
)
func TestAdd(t *testing.T) {
a := 1
b := 2
expected := a + b
if got := Add(a, b); got != expected {
t.Errorf("Add(%d, %d) = %d, didn't return %d", a, b, got, expected)
}
}
func TestSubtract(t *testing.T) {
a := 1
b := 2
expected := a - b
if got := Subtract(a, b); got != expected {
t.Errorf("Subtract(%d, %d) = %d, didn't return %d", a, b, got, expected)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment