Skip to content

Commit

Permalink
replaced Setup with New
Browse files Browse the repository at this point in the history
breaks api, but more idiomatic and nobody uses the lib yet
  • Loading branch information
mg6maciej committed Jan 6, 2015
1 parent b0ac636 commit 4d30eb0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ And just start using it.

```go
func TestPerfectNumber(t *testing.T) {
assert := assert.Setup(t)
assert := assert.New(t)
num := ComputePerfectNumber()
assert.ThatInt(num).
IsEqualTo(6).
Expand Down
2 changes: 1 addition & 1 deletion error_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestErrorLoggerDifferentFileSameLine(t *testing.T) {
}

func setupWithLogger(t *testing.T) (provider *Provider, buffer *bytes.Buffer, logger errorLogger) {
provider = Setup(t)
provider = New(t)
buffer = &bytes.Buffer{}
logger = &errorLoggerImpl{writer: buffer}
return
Expand Down
4 changes: 2 additions & 2 deletions location_provider_moar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package assert
import "testing"

func TestLocationProviderCorrectFileName(t *testing.T) {
assert := Setup(t)
assert := New(t)
thisLineLocation := provideLocation(0)
assert.That(thisLineLocation).IsEqualTo(
&location{"TestLocationProviderCorrectFileName", "location_provider_moar_test.go", 7},
)
}

func TestLocationProviderCalledFromAnotherFile(t *testing.T) {
assert := Setup(t)
assert := New(t)
insideAnotherFunctionLocation := anotherFunction()
assert.That(insideAnotherFunctionLocation).IsEqualTo(
&location{"TestLocationProviderCalledFromAnotherFile", "location_provider_test.go", 6},
Expand Down
6 changes: 3 additions & 3 deletions location_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ func anotherFunction() *location {
}

func TestLocationProvider(t *testing.T) {
assert := Setup(t)
assert := New(t)
thisLineLocation := provideLocation(0)
assert.That(thisLineLocation).IsEqualTo(
&location{"TestLocationProvider", "location_provider_test.go", 11},
)
}

func TestLocationProviderCalledFromAnotherFunction(t *testing.T) {
assert := Setup(t)
assert := New(t)
insideAnotherFunctionLocation := anotherFunction()
assert.That(insideAnotherFunctionLocation).IsEqualTo(
&location{"TestLocationProviderCalledFromAnotherFunction", "location_provider_test.go", 6},
)
}

func TestLocationProviderPanicsWhenUsedIncorrectly(t *testing.T) {
assert := Setup(t)
assert := New(t)
defer func() {
r := recover()
assert.That(r).IsEqualTo("you shall not pass!")
Expand Down
2 changes: 1 addition & 1 deletion provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
)

func Setup(t *testing.T) *Provider {
func New(t *testing.T) *Provider {
return setupImpl(t, theLogger)
}

Expand Down
14 changes: 7 additions & 7 deletions util_prime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package assert
import "testing"

func TestLessThanTwoIsNotPrime(t *testing.T) {
assert := Setup(t)
assert := New(t)
assert.ThatBool(isPrime(-1000)).IsFalse()
assert.ThatBool(isPrime(-100)).IsFalse()
assert.ThatBool(isPrime(-10)).IsFalse()
Expand All @@ -13,41 +13,41 @@ func TestLessThanTwoIsNotPrime(t *testing.T) {
}

func TestSmallNumbersArePrime(t *testing.T) {
assert := Setup(t)
assert := New(t)
assert.ThatBool(isPrime(2)).IsTrue()
assert.ThatBool(isPrime(3)).IsTrue()
assert.ThatBool(isPrime(5)).IsTrue()
assert.ThatBool(isPrime(7)).IsTrue()
}

func TestSmallNumbersAreNotPrime(t *testing.T) {
assert := Setup(t)
assert := New(t)
assert.ThatBool(isPrime(4)).IsFalse()
assert.ThatBool(isPrime(6)).IsFalse()
assert.ThatBool(isPrime(8)).IsFalse()
assert.ThatBool(isPrime(9)).IsFalse()
}

func TestBigNumbersArePrime(t *testing.T) {
assert := Setup(t)
assert := New(t)
assert.ThatBool(isPrime(2311)).IsTrue()
assert.ThatBool(isPrime(3203)).IsTrue()
assert.ThatBool(isPrime(1321)).IsTrue()
}

func TestBigNumbersAreNotPrime(t *testing.T) {
assert := Setup(t)
assert := New(t)
assert.ThatBool(isPrime(1001)).IsFalse()
assert.ThatBool(isPrime(5251)).IsFalse()
assert.ThatBool(isPrime(2809)).IsFalse()
}

func TestReallyBigNumberIsPrime(t *testing.T) {
assert := Setup(t)
assert := New(t)
assert.ThatBool(isPrime(2147483647)).IsTrue()
}

func TestReallyBigNumberIsNotPrime(t *testing.T) {
assert := Setup(t)
assert := New(t)
assert.ThatBool(isPrime(46337 * 46337)).IsFalse()
}

0 comments on commit 4d30eb0

Please sign in to comment.