Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 5, 2019 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/99dfa462c15a4b3c4f7749fe63e2b976 to your computer and use it in GitHub Desktop.
Save parzibyte/99dfa462c15a4b3c4f7749fe63e2b976 to your computer and use it in GitHub Desktop.
package main
/*
Probar la función Sumar que existe en main.go
@author parzibyte
*/
// Importa el paquete:
import "testing"
// Escribe TestXXXX en donde XXXX es el nombre de la función original
func TestSumar(t *testing.T) { // Recibir struct de tipo testing.T
resultado := sumar(1, 2)
resultadoEsperado := 3
if resultado != resultadoEsperado {
t.Errorf("Error en %s. Se esperaba %d pero el resultado fue %d", t.Name(), resultadoEsperado, resultado)
}
// Y si no, o sea, si todo va bien, no hacemos nada
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment