Ad
  • Custom User Avatar

    C++ tests can generate an index of 0. This is outside the defined range.

  • Custom User Avatar

    Added a couple fixed cases with the full alphabet, lower and upper case, as well as more punctuation. Copied the same cases to my other translations.

  • Custom User Avatar

    Yes. If the predicate is only expecting 1 arg, then the 2nd one will be ignored. The NULL is just a placeholder. Depending on the calling convention, stack or registers, you'll end up with an unused NULL ptr on the stack or a zeroed out register that's ignored. A problem does arise when you pass too few parameters and the callee tries to use uninitialized garbage data.

    Of course, this is all dependent on the user calling the reentrant version with a two-arg predicate, and the non-reentrant version with either a one-arg predicate or a two-arg predicate that handles NULL correctly. You could write a single two-arg predicate that functions as a one-arg version depending on the 2nd arg's value, then use that for both reentrant and non-reentrant applications.

    If you haven't yet, take a look at variable arguments handling in C (stdarg.h). The initial parameter(s) must be strictly defined, as they tell the function how many additional parameters are passed, and potentially how to interpret them. See the printf family of functions. I know that while javac verifies all the parameters passed to String.format, I've never seen a C compiler parse the format string. It's done at run-time.

  • Custom User Avatar

    Added an empty string test case to my translations. Broke two C solutions and four Java solutions with the change. People, come on! :-P

    The JavaScript test framework breaks when fed an empty string, so I'll leave that to the original author. Not touching the other languages.

  • Custom User Avatar

    Java, C++, C, and Perl translations available. Please review.

  • Custom User Avatar

    Understood, here's what it'll print now.

    Invalid quarter for month 12, expected:<4> but was:<0>
    

    I'll update my Perl and NASM translations accordingly.

  • Custom User Avatar

    Done. The message looks like this:

    Invalid quarter, expected:<1> but was:<0>
    
  • Custom User Avatar

    Java, Perl, and NASM translations available. Please review.

  • Custom User Avatar
    • Random number generator needs to be seeded.
    • The solution function can be called by the user, allowing the tests to be passed with this, "auto quarter_of = [](int month){return solution(month);};". You need to either move this logic into the Get_quarter method, make solution a method of the Random_tests class, or declare solution to be static so it's not accessible from outside the testing framework.
    • The formatting is inconsistent and sloppy. Sometimes the opening { is cuddled, other times it's on the next line. Sometimes indentation is 2 spaces, and other times it's 4.
  • Custom User Avatar

    Java, C, C++, and Perl translations available. Please review.

  • Custom User Avatar

    Well replace would reduce the number of characters before the split, resulting in a shorter array for filter to spin through. Since each array element is a string, then fewer String objects are created.

  • Custom User Avatar

    C and C++ translations. Please review.

  • Custom User Avatar
  • Custom User Avatar

    @Unnamed, I've forked the C translation. Once it's approved I'll fork this one.

  • Custom User Avatar

    @Unnamed, try the forked version.

  • Loading more items...