I’m currently mentoring someone on the Logs, logs, logs! exercise and they have the following implementation for the WithinLimit()
function:
func WithinLimit(log string, limit int) bool {
countChar := 0
for _ , valueString := range log {
if valueString < 127 {
countChar++
}
}
return countChar < limit
}
I have two questions about this:
- My understanding is that this implementation is wrong. It should count all characters, not check if the number of ASCII characters is one below the limit (or less). Is that correct?
- If I understood correctly, is it worth it to add an extra test case for this exercise? Either one of the following two example cases would catch the issue:
{
name: "exact limit - ASCII only",
log: "exercism",
limit: 8,
want: true,
},
{
name: "over limit - extra emoji",
log: "exercism❗❗",
limit: 9,
want: false,
},