forked from steger/pr3-ws202526
implement myMath module
parent
19379c65da
commit
ff881930f5
|
|
@ -0,0 +1,5 @@
|
|||
module gitty.informatik.hs-mannheim.de/steger/pr3-code/go/03-modules/myMath
|
||||
|
||||
go 1.25.0
|
||||
|
||||
require github.com/google/uuid v1.6.0
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
|
|
@ -1,5 +1,19 @@
|
|||
package main
|
||||
|
||||
func main() {
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
mm "gitty.informatik.hs-mannheim.de/steger/pr3-code/go/03-modules/myMath"
|
||||
//_ "gitty.informatik.hs-mannheim.de/steger/pr3-code/go/03-modules/myMath"
|
||||
|
||||
"github.com/google/uuid"
|
||||
//run go get github.com/google/uuid
|
||||
//or go mod tidy => go.sum
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(mm.Add(1, 2))
|
||||
|
||||
id := uuid.New()
|
||||
fmt.Println("Generated UUID:", id)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package myMath_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitty.informatik.hs-mannheim.de/steger/pr3-code/go/03-modules/myMath"
|
||||
)
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
sum := myMath.Add(2, 3)
|
||||
if sum != 5 {
|
||||
t.Errorf("Add(2,3) = %v, want %v", sum, 5)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMin(t *testing.T) {
|
||||
type args struct {
|
||||
in0 int
|
||||
in1 int
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want int
|
||||
}{
|
||||
{"first greater", args{3, 2}, 2},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := myMath.Min(tt.args.in0, tt.args.in1); got != tt.want {
|
||||
t.Errorf("Min() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue