Fixing tests to compare recovered value with the error instead of nil

This commit is contained in:
Denis-Cosmin Nutiu 2017-10-28 23:15:48 +03:00
parent f45beb7d23
commit 7f447978a2

View file

@ -39,7 +39,7 @@ func TestStringStack_CanPush(t *testing.T) {
func TestStringStack_StackOverflows(t *testing.T) { func TestStringStack_StackOverflows(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { if r := recover(); r != StackOverflowError {
t.Errorf("StringStack: Capacity of 0 doesn't overflow on Push()!") t.Errorf("StringStack: Capacity of 0 doesn't overflow on Push()!")
} }
}() }()
@ -50,7 +50,7 @@ func TestStringStack_StackOverflows(t *testing.T) {
func TestStringStack_InvalidType(t *testing.T) { func TestStringStack_InvalidType(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { if r := recover(); r != StackInvalidTypeError {
t.Errorf("StringStack: Push() pushed a non-string type.") t.Errorf("StringStack: Push() pushed a non-string type.")
} }
}() }()
@ -118,7 +118,7 @@ func TestStringStack_Top(t *testing.T) {
func TestStringStack_TopUnderflow(t *testing.T) { func TestStringStack_TopUnderflow(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { if r := recover(); r != StackUnderflowError {
t.Errorf("StringStack: Top() on empty stack didn't underflow.") t.Errorf("StringStack: Top() on empty stack didn't underflow.")
} }
}() }()