the first one
This commit is contained in:
@@ -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
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
module calculator
|
||||||
|
|
||||||
|
go 1.22.4
|
||||||
|
|
||||||
Reference in New Issue
Block a user