Ad
  • Custom User Avatar

    You're very welcome.

  • Custom User Avatar

    Thank you very much :)

  • Custom User Avatar

    Quite a fancy kata of the ASCII art series, well done.

  • Custom User Avatar
  • Custom User Avatar

    Approved by someone (can you resolve the suggestion?)

  • Custom User Avatar

    This one LGTM! Tried to approve but apparently if the author is active you have to wait a week to approve. If nobody raises any further issues in the discourse (incl. the author themself), I'll approve it in a week's time

  • Custom User Avatar

    No worries, it's fixed. Please review. Also, I'd like to thank you for all the effort and time you put in to help me correct this one, I really appreciate it. If you don't mind, I have another translation from this kata series which I corrected side-by-side with this one so it should be almost ready to approve as well.

  • Custom User Avatar

    All is good now! I just realized I goofed up when I told you to put no_of_staff outside. It's meant to be different each time, right? Just put it back in and I'll approve. Sorry, it's totally my bad

  • Custom User Avatar

    Fixed some bugs and made some improvements, ready for review!

  • Custom User Avatar

    Did the above changes. Would note though that the way you initialized the "gen" variable caused the compiler to make a most vexing parse error, but I found a way to corretly initialize.

  • Custom User Avatar

    Looks very good and almost ready to approve. Just correct < 80 in your reference solution and submission solution to <= 80 and take the engines, distributions, places, base, no_of_staff out of the get_random_staff function and instead just paste them directly above the function. Recreating them within every call is unnecessary and suboptimal. This might mean you may have to use braces instead of parentheses (so C++ doesn't parse them as function declarations). Also, move the using type alias into the private section too, so your type aliases are invisible to the user. Other than this, I have no comments. Looks good! Just rearrange your code into:

    private:
          using Staff = std::map<std::string, std::string>;
          std::string ref_sol(const Staff &staff){
              // ...
          }
          // Note the angular brackets for initialization instead of round parentheses.
          std::mt19937 gen{std::random_device{}}; // standard mersenne_twister_engine seeded with random device
          std::uniform_int_distribution<std::size_t> dis{0, 25}; // emp_name_chars
          // Other distributions, same as above...
          std::array<std::string, 10> places = {"accounts","finance","canteen","regulation","trading","change","IS","retail","cleaning","pissing about"};
          std::string base = "abcdefghijklmnopqrstuvwxyz";
          int no_of_staff = dis3(gen);
    
          Staff get_random_staff() {
              // ...
          }
    };
    

    In the fixed tests, just define the type alias inside the It. Try to reduce the scope of your aliases as much as possible.

  • Custom User Avatar

    Somehow I didn't save the changes... Nevertheless I changed it again, so please review now

  • Custom User Avatar

    I don't see any of the changes. Are you sure you've clicked publish? Also about where to put functions, Describe is just a macro and it's a struct behind the scenes. You can have a private section within it. It's also a good place to put your reference solution too (more info here). Just do this:

    Describe(whatever)
    {
        // It(blah_blah) {....}
        // Other It blocks...
    private:
        // Functions and other 'secret' variables can go here.
        // If you want, you can put the engine and distributions here too.
        std::map<std::string, std::string> gen_random_test()
        {
            // return ...
        }
    };
    
  • Custom User Avatar

    First of all, thank you for the detailed review. Second of all, I think I fixed all of the above, if you'd be so kind to check :)

    Also, I tried to define the get_random_staff inside of the It() block, but it said it couldn't be defined there (I moved it outside of the It but still inside the Describe). Do you know why that is?
    Thanks!

  • Custom User Avatar

    Good job! I have a few suggestions:

    • You correctly use std::size_t for the distributions, but no_of_staff and q and l (the nested loop variables) should also be std::size_t. Intermixing integer types causes the tests to generate a warning in the log.
    • Try not to mix different naming conventions. The names boredom and Myboredom are inconsistent with each other style-wise. Same with BAS, no_of_staff, etc. You seem to lean most towards snake case, so maybe turn most things into snake case.
    • Try to refactor some things into functions for ease of readability. For example, as so:
    for (int x = 0; x < NO_OF_TESTS; x++) {
        auto rand_staff = get_random_staff();
        auto expected   = ref_sol(random_staff);
        Assert::That(boredom(random_staff), Equals(expected));
    }
    
    • Add feedback messages for when the user fails a test. Now, this would be cumbersome manually. Just #include <fmt/ranges.h> and use the below template for your assertions. This might mean you have to store the std::maps in the fixed tests into variables so you can reference them to generate feedback messages:
    Assert::That(boredom(/* name of staff variable */), Equals(/* expected */), ExtraMessage(fmt::format("Incorrect output for staff = {}:\n", /* name of staff variable */)));
    
  • Loading more items...