Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • A separate test for NULL may be good, but I don't think it's that necessary. free can be called with NULL.

  • Or even better approach if you need some other message for NULL:

    if (!actual)
        cr_assert_fail("NULL Message...");
    else {
        cr_assert_str_eq(actual, expected, "Fail Message...");
  • cr_assert_str_eq crashes if passed NULL and then you need to check once again to free
    So the best approach to test also for NULL and then to free is

    if (!actual || strcmp(actual, expected))
        cr_assert_fail("Fail Message...");
    else {
  • .

  • Javascript translation kumited. Review and approve.

  • Java Translation. Please review

  • Maybe the C or NASM versions are interesting but this is yet another boring string manipulation kata in Python.

  • While it may not be an exact duplicate, there are already way too many such simple string manipulation katas on CW.

  • Approved, thanks.

  • Python translation. Please, review and approve.

  • strcmp returns an integer so it has to be asserted by cr_assert_eq instead.
    I will change the random tests with cr_assert_eq and strcmp.

    Or you could have looked up the unittest library documentation and found out that cr_assert_str_eq(actual, expected, format_string, ...) already has all the needed functionality. Anyway, now it's fixed.

  • It is now showing this message when the random test fails.

     Expected Result: ReRaXiP3DeGa3NmXzO+5Sq++WrUoTsJ-FaNy1JyWlO-NnYiBuVqSfH33MfJnAgO5Ng55OhI_OnK_KgJ1JmUdBuKsAwZn_DzGdQp_
     Actual Result: ReRaXiP3DeGa3NmXzO+5Sq++WrUoTsJ-FaNy1JyWlO-NnYiBuV


  • This comment is hidden because it contains spoiler information about the solution

  • So here, we should show the output of the expected result and the actual result?
    Good idea for debugging purpose, btw.

  • The user has no idea what's wrong with the output, maybe?

  • Loading more items...