-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error messages in "triangle" #525
Comments
I think the point with the |
vaeng
added a commit
that referenced
this issue
Oct 17, 2023
BREAKING CHANGE: forces students to use enums closes #525
I think this is a very helpful change. I made a PR: #726 |
vaeng
added a commit
that referenced
this issue
Dec 3, 2023
BREAKING CHANGE: forces students to use enums closes #525
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The tests in the exercise "triangle" compare the result of the function with the
operator==
like this:By default Catch2 prints an
enum
orenum class
like an integer:That
0 == 1
is neither expressive nor helpful.Also, I've mentored many solutions that used something other than an
enum
, e.g.:Catch2 has the macro
CATCH_REGISTER_ENUM()
for better error messages when working with enums (see the documentation).By adding a few lines somewhere at the beginning of
triangle_test.cpp
:we would get better error messages:
and that would guide students towards using
enum
orenum class
.AFAIK there are only three possible problems:
When the students read the tests they will be guided towards an
enum
orenum class
, they are less likely to "discover" enums on their own when searching for the best solution. But I'd rather view that "guidance" as positive.That would effectively force the use of
enum
orenum class
, any of those alternative approaches (see above) would lead to a compilation error. IMHO that's not a problem for us because we want idiomatic solutions and that'senum
or betterenum class
.If the students want to add a fourth
degenerate
enumerator (for the bonus part in "Dig Deeper"), they will have to add that enumerator in the tests, too, or they wil get this "unexpected enum value":IMHO the benefits outweigh these problems.
What do you folks think?
The text was updated successfully, but these errors were encountered: