You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt"
"testing"
)
/* - Nos capítulos seguintes, uma das coisas que veremos é testes.
- Para testar sua habilidade de se virar por conta própria... desafio:
- Utilizando as seguintes fontes: https://godoc.org/testing & http://www.golang-book.com/books/intr...
- Tente descobrir por conta própria como funcionam testes em Go.
- Pode usar tradutor automático, pode rodar código na sua máquina, pode procurar no Google. Vale tudo.
- O exercício é: crie um teste simples de uma função ou método ou pedaço qualquer de código. */
func Mostra(x int) int {
total := (x + 100)
fmt.Println(total)
return x
}
func TestMostra(t *testing.T) {
v := Mostra(5)
if v != 4 {
t.Errorf("Mostra(4) -> Valor inserido: %d ; Precisa de: 4", v)
}
}
Output FAIL
=== RUN TestMostra
105
prog.go:24: Mostra(4) -> Valor inserido: 5 ; Precisa de: 4
--- FAIL: TestMostra (0.00s)
FAIL
1 test failed.
Output PASS
=== RUN TestMostra
104
--- PASS: TestMostra (0.00s)
PASS
All tests passed.
Exercício: Capítulo 24, Exercício 5 (Nível: 11)
Use esta thread para compartilhar sua solução, discutir o exercício com os colegas e pedir ajuda caso tenha dificuldades!
The text was updated successfully, but these errors were encountered: