-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating assert as util and a separate test for all Assert* methods
- Loading branch information
1 parent
2b3aa08
commit 756bbc6
Showing
2 changed files
with
28 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
package util | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
"reflect" | ||
) | ||
|
||
|
||
func TestAssert(t *testing.T) { | ||
log.Println("Some testing here!") | ||
AssertEqual(1, 1, t) | ||
AssertEqual([1]int{1}, [1]int{1}, t) | ||
} | ||
|
||
func AssertEqual(a interface{}, b interface{}, t *testing.T) { | ||
if reflect.DeepEqual(a, b) { | ||
return | ||
} | ||
t.Errorf("Received %v (type %v), expected %v (type %v)", a, reflect.TypeOf(a), b, reflect.TypeOf(b)) | ||
} | ||
|
||
|
||
func AssertTrue(a bool, t *testing.T) { | ||
if a { | ||
return | ||
} | ||
t.Errorf("Received %v (type %v), expected %v (type %v)", a, reflect.TypeOf(a), !a, reflect.TypeOf(a)) | ||
} | ||
|
||
func AssertFalse(a bool, t *testing.T) { | ||
AssertTrue(!a, t) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package util | ||
|
||
|
||
import ( | ||
"log" | ||
"testing" | ||
) | ||
|
||
|
||
func TestAssert(t *testing.T) { | ||
log.Println("Some testing here!") | ||
AssertEqual(1, 1, t) | ||
AssertEqual([1]int{1}, [1]int{1}, t) | ||
AssertTrue(true, t) | ||
AssertFalse(false, t) | ||
} |