diff --git a/calculator/calculator.go b/calculator/calculator.go old mode 100644 new mode 100755 index 28d9f52..55fe9df --- a/calculator/calculator.go +++ b/calculator/calculator.go @@ -1,5 +1,10 @@ // 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 + return a + b +} + +func Subtract(a, b float64) float64 { + return b - a } diff --git a/calculator/calculator_test.go b/calculator/calculator_test.go old mode 100644 new mode 100755 index 4ac282c..20c6f88 --- a/calculator/calculator_test.go +++ b/calculator/calculator_test.go @@ -1,16 +1,24 @@ package calculator_test import ( - "calculator" - "testing" + "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) - } + t.Parallel() + var want float64 = 4 + got := calculator.Add(2, 2) + if 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) + } +} diff --git a/calculator/go.mod b/calculator/go.mod old mode 100644 new mode 100755 diff --git a/test-vs-code/main.go b/test-vs-code/main.go new file mode 100644 index 0000000..0f3d19c --- /dev/null +++ b/test-vs-code/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("hello World") +}