Skip to content

Commit

Permalink
Add calc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMatthes committed Apr 26, 2024
1 parent 26e4e8e commit 495acb7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
11 changes: 11 additions & 0 deletions calc/abs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package calc

import (
"testing"
)

func TestAbs(t *testing.T) {
if Abs(-1) != 1 || Abs(1) != 1 {
t.Errorf("abs doesn't work")
}
}
21 changes: 21 additions & 0 deletions calc/max_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package calc

import "testing"

func TestMax(t *testing.T) {
if Max(1_000_000, 2) != 1_000_000 {
t.Errorf("max doesn't work")
}
if Max(-1, 1_000_000) != 1_000_000 {
t.Errorf("max doesn't work")
}
}

func TestMax64(t *testing.T) {
if Max64(1_000_000_000_000, 2) != 1_000_000_000_000 {
t.Errorf("max64 doesn't work")
}
if Max64(-1, 1_000_000_000_000) != 1_000_000_000_000 {
t.Errorf("max64 doesn't work")
}
}
21 changes: 21 additions & 0 deletions calc/min_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package calc

import "testing"

func TestMin(t *testing.T) {
if Min(1_000_000, 2) != 2 {
t.Errorf("Min doesn't work")
}
if Min(-1, 1_000_000) != -1 {
t.Errorf("Min doesn't work")
}
}

func TestMin64(t *testing.T) {
if Min64(1_000_000_000_000, 2) != 2 {
t.Errorf("Min64 doesn't work")
}
if Min64(-1, 1_000_000_000_000) != -1 {
t.Errorf("Min64 doesn't work")
}
}

0 comments on commit 495acb7

Please sign in to comment.