Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
37 lines (31 sloc) 881 Bytes
package fizzbuzz
import (
"strconv"
"github.com/leanovate/gopter"
"github.com/leanovate/gopter/gen"
"github.com/leanovate/gopter/prop"
"testing"
)
func Test_ValidateFizzBuzz(t *testing.T) {
parameters := gopter.DefaultTestParameters()
parameters.MinSuccessfulTests = 10000
properties := gopter.NewProperties(parameters)
properties.Property("FizzBuzz Returns Correct String", prop.ForAll(
func(num int) bool {
str := fizzBuzz(num)
switch str {
case "Fizz":
return (num % 3 == 0) && !(num % 5 == 0)
case "Buzz":
return (num % 5 == 0) && !(num % 3 == 0)
case "FizzBuzz":
return (num % 3 == 0) && (num % 5 == 0)
default:
expectedStr := strconv.Itoa(num)
return !(num % 3 == 0) && !(num % 5 == 0) && expectedStr == str
}
},
gen.Int(),
))
properties.TestingRun(t)
}
You can’t perform that action at this time.