diff --git a/.travis.yml b/.travis.yml index f369c43..449e3bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,11 @@ script: - $(exit $(go fmt ./... | grep -v /vendor/ | wc -l)) # Make sure go generate is in sync. - - go generate ./... + - go generate ./... && go install && go generate ./... - $(exit $(git status --porcelain | wc -l)) # Run tests. - - go test -race ./... + - go test -race ./pie -coverprofile=coverage.txt -covermode=atomic + +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 1dd82b4..8659688 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # 🍕 `github.com/elliotchance/pie` [![GoDoc](https://godoc.org/github.com/elliotchance/pie?status.svg)](https://godoc.org/github.com/elliotchance/pie) [![Build Status](https://travis-ci.org/elliotchance/pie.svg?branch=master)](https://travis-ci.org/elliotchance/pie) +[![codecov](https://codecov.io/gh/elliotchance/pie/branch/master/graph/badge.svg)](https://codecov.io/gh/elliotchance/pie) **Enjoy a slice!** `pie` is a code generator for dealing with slices that focuses on type safety, performance and immutability. diff --git a/pie/myints_test.go b/pie/myints_test.go new file mode 100644 index 0000000..49cc10a --- /dev/null +++ b/pie/myints_test.go @@ -0,0 +1,18 @@ +package pie + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +// There tests are just to make sure that the select functions for myInts are +// generated. The more extensive tests for these functions are in ints_test.go + +func TestMyInts_Average(t *testing.T) { + assert.Equal(t, 0.0, myInts(nil).Average()) + assert.Equal(t, 4.333333333333333, myInts{1, 5, 7}.Average()) +} + +func TestMyInts_Sum(t *testing.T) { + assert.Equal(t, 13, myInts{1, 5, 7}.Sum()) +}