(t *testing.T)
| 5 | ) |
| 6 | |
| 7 | func TestSimple(t *testing.T) { |
| 8 | target := "This is a genetic algorithm to evaluate, combine, evolve and mutate a string!" |
| 9 | charmap := []rune(" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,;!?+-*#@^'èéòà€ù=)(&%$£/\\") |
| 10 | |
| 11 | res, err := GeneticString(target, charmap, &Conf{}) |
| 12 | if err != nil { |
| 13 | t.Errorf("Unexpected error: %v\n", err) |
| 14 | } |
| 15 | |
| 16 | got := res.Best |
| 17 | |
| 18 | if got.Value != float64(1.0) { |
| 19 | t.Errorf("Target value not reached\nwant: %f\n, got: %f\n", float64(1.0), got.Value) |
| 20 | } |
| 21 | |
| 22 | if got.Key != target { |
| 23 | t.Errorf("Target string not reached\nwant: %s\n, got: %s\n", target, got.Key) |
| 24 | } |
| 25 | } |
nothing calls this directly
no test coverage detected