August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this section, you will learn how to find more information about the code coverage of your programs. There are times when seeing the code coverage of your programs can reveal issues and bugs with your code, so do not underestimate its usefulness.
The Go code of codeCover.go is as follows:
package codeCover
func fibo1(n int) int {
if n == 0 {
return 0
} else if n == 1 {
return 1
} else {
return fibo1(n-1) + fibo1(n-2)
}
}
func fibo2(n int) int {
if n >= 0 {
return 0
} else if n == 1 {
return 1
} else {
return fibo1(n-1) + fibo1(n-2)
}
}
The implementation of fibo2() is erroneous because it returns 0 all the time. A result of this bug is that most of the Go code of fibo2() will never get executed.
The test code that can ...
Read now
Unlock full access