Micro Blog passes incorrect solutions

The Micro Blog PowerShell exercise allows incorrect solutions.

I think a correct solution should be:

$Post.Substring(0, [math]::Min($Post.Length, 5))

However, looking through the other solutions I see

$Post.Substring(0,4)

which should return a 4 length string, and produce an exception on inputs shorter than 4.

Playing around, this also passed:

$Post[0]

I have no idea of PowerShell, but it looks like returning anything passes the tests. Maybe there is an issue with the way of testing this… @glaxxie can you look at this?

1 Like

thanks @mk-mxp for the head up
and sorry for the late reply, this one error is entirely on me. the test suite calling the function incorrectly so it will pass anything and i didnt realize my mistake
it should be

Invoke-MicroBlog -Post "Hello there"

instead of

Invoke-MicroBlog("Hello there")

like some other languages
a fix has been pushed and is waiting for review and then merge

1 Like

@Dabombber the issue should be fixed now, thank you for notifying and sorry for the delay.

Here is a hint for this exercise to save you some time : this exercise deals with Unicode text encoding, so a simple substring very likely won’t work for all cases, you should google System.Globalization.StringInfo and proceed from there