2
1
Fork 0

implement myMath module

main^2
Sebastian Steger 2025-08-20 09:20:37 +00:00
parent 3b64985275
commit c2ebf023c4
4 changed files with 57 additions and 1 deletions

View File

@ -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

View File

@ -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=

View File

@ -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)
}

View File

@ -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)
}
})
}
}