the first one
This commit is contained in:
commit
2fecd78ff3
5
calculator/calculator.go
Normal file
5
calculator/calculator.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Package calculator does simple calculations.
|
||||
package calculator // Add takes two numbers and returns the result of adding them together.
|
||||
func Add(a, b float64) float64 {
|
||||
return a + b
|
||||
}
|
||||
16
calculator/calculator_test.go
Normal file
16
calculator/calculator_test.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package calculator_test
|
||||
|
||||
import (
|
||||
"calculator"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
t.Parallel()
|
||||
var want float64 = 4
|
||||
got := calculator.Add(2, 2)
|
||||
if want != got {
|
||||
t.Errorf("want %f, got %f", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
4
calculator/go.mod
Normal file
4
calculator/go.mod
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
module calculator
|
||||
|
||||
go 1.22.4
|
||||
|
||||
Loading…
Reference in New Issue
Block a user