-
-
Save parzibyte/99dfa462c15a4b3c4f7749fe63e2b976 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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