github.com/giovannyortegon/go@v0.0.0-20220115155912-8890063f5bdd/src/Profesional/TestUnitario/testunitario/adicion_test.go (about) 1 package testunitario 2 3 import "testing" 4 5 /* 6 func TestSuma(t *testing.T) { 7 total := Suma(5, 5) 8 9 if total != 10 { 10 t.Errorf("El resutado es %d y se esperaba %d\n", total, 10) 11 } 12 }*/ 13 14 func TestSuma(t *testing.T) { 15 operandos := []struct { 16 a int 17 b int 18 c int 19 }{ 20 {1, 2, 3}, 21 {2, 2, 4}, 22 {25, 25, 50}, 23 } 24 25 for _, values := range operandos { 26 total := Suma(values.a, values.b) 27 28 if total != values.c { 29 t.Errorf("Suma incorrecta, tiene %d se espera %d", total, values.c) 30 } 31 } 32 }