divide gprs pfo to several clusters
This commit is contained in:
Regular → Executable
+6
-1
@@ -1,5 +1,10 @@
|
|||||||
// Package calculator does simple calculations.
|
// Package calculator does simple calculations.
|
||||||
package calculator // Add takes two numbers and returns the result of adding them together.
|
package calculator // Add takes two numbers and returns the result of adding them together.
|
||||||
|
|
||||||
func Add(a, b float64) float64 {
|
func Add(a, b float64) float64 {
|
||||||
return a + b
|
return a + b
|
||||||
|
}
|
||||||
|
|
||||||
|
func Subtract(a, b float64) float64 {
|
||||||
|
return b - a
|
||||||
}
|
}
|
||||||
|
|||||||
Regular → Executable
+16
-8
@@ -1,16 +1,24 @@
|
|||||||
package calculator_test
|
package calculator_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"calculator"
|
"calculator"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAdd(t *testing.T) {
|
func TestAdd(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
var want float64 = 4
|
var want float64 = 4
|
||||||
got := calculator.Add(2, 2)
|
got := calculator.Add(2, 2)
|
||||||
if want != got {
|
if want != got {
|
||||||
t.Errorf("want %f, got %f", want, got)
|
t.Errorf("want %f, got %f", want, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSubtract(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
var want float64 = 2
|
||||||
|
got := calculator.Subtract(4, 2)
|
||||||
|
if want != got {
|
||||||
|
t.Errorf("want %f, got %f", want, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Regular → Executable
@@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("hello World")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user