Ad
  • Custom User Avatar

    LooooooooooooooooooooooooooooooooooooooooooooooooL
    Laugh with cry
    Like in the real life

  • Default User Avatar
  • Custom User Avatar

    also, what is the point of randomizing ntest between 99 and 100 in ntest = ge_uint_of(99, 100);? Why not 100 tests every time ?

    To make life of half of users 1% easier than life of the other 50% of users, duh! Isn't this obvious?

  • Custom User Avatar

    My point is that

    if (strcmp(aoc->actual, aoc->expected))
        cr_assert_fail("Expected: \"%s\"\n*Actual:* \"%s\"\n  String: \"%s\"", aoc->expected, aoc->actual, aoc->str);
    else
        cr_assert(1);
    

    is faster then

    cr_assert_str_eq(aoc->expected, aoc->actual, "Expected: \"%s\"\n*Actual:* \"%s\"\n  String: \"%s\"", aoc->expected, aoc->actual, aoc->str);
    
    • But anyway changed to cr_assert_str_eq()
    • changed outp to be a local str to prevent corrupted output while printing caused by user modification
    • Switched to C18
    • did not change ntest as 've told earlier... 'm on the point that the random test should have a random number of cases!
  • Default User Avatar
    • my point was that instead of:

      if (strcmp(aoc->actual, aoc->expected))
          cr_assert_fail("Expected: \"%s\"\n*Actual:* \"%s\"\n  String: \"%s\"", aoc->expected, aoc->actual, aoc->str);
      else
          cr_assert(1);
      

      you could write:

      cr_assert_str_eq(aoc->actual, aoc->expected, "Expected: \"%s\"\n*Actual:* \"%s\"\n  String: \"%s\"", aoc->expected, aoc->actual, aoc->str);
      

      this is what cr_assert_str_eq() is for, it calls strcmp() behind the scenes.

    • Also, it seems that outp is never used in assert_case() ? In that case, it should be removed.

    • C version is the old c11 version, you have to upgrade it to C18

    • also, what is the point of randomizing ntest between 99 and 100 in

      ntest = ge_uint_of(99, 100);
      

      ? Why not 100 tests every time ?

  • Custom User Avatar

    Done

    • reminded the user to terminate outp
    • set to return outp instead of NULL
    • filled actual with ??? but in ge_case instead of assert_case

    cr_assert_str_eq() used to evaluate all the argumets even in case of success. Though the things could change...

  • Default User Avatar
    • in the initial code, you should write a comment telling the user to:

      • nul-terminate outp;
      • return outp (and this should be done instead of return NULL)
    • in assert_set(), you should fill outp with some nonzero byte to make sure users who forget to nul-terminate do not pass the tests, e.g.

    char outp[3] = "@@@";
    
    • why don't you use cr_assert_str_eq() in assert_set() ?
  • Custom User Avatar

    That was the original idea... Not mine))

  • Custom User Avatar

    Dynamic allocation of two-character long string? Is this really necessary?

  • Custom User Avatar

    Modifed Generic Test and added Random Test...
    Kept the handicraftsman's solution!
    But there were description merge conflicts!
    Please, review, and approve...

  • Custom User Avatar

    This needs random test cases befor I'll approve it.

  • Custom User Avatar

    They use loops internally.