Skip to content
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

refactor: Remove usage of fmt in library #72 #81

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

MichaeINeumann
Copy link
Contributor

do the string concatenation manually Issue:#72

@bobluppes @joweich I created my own PR to see if the code would pass the test. I am new here and have no experience. I don't know if this is the right approach in this case. Perhaps you should delete this duplicate PR. #75

Michael Neumann added 2 commits August 17, 2023 19:52
do the string concatenation manually
the exact type of current.id is unknown, try using a generic method to convert this value into a string.
@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (3933598) 99.67% compared to head (910b02a) 99.67%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #81   +/-   ##
=======================================
  Coverage   99.67%   99.67%           
=======================================
  Files          23       23           
  Lines        1226     1234    +8     
=======================================
+ Hits         1222     1230    +8     
  Misses          4        4           
Files Changed Coverage Δ
include/graaflib/algorithm/shortest_path.tpp 98.98% <100.00%> (+0.08%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@bobluppes bobluppes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MichaeINeumann, thanks for working on this! Don't worry about being new to C++, I think this is a nice introductory ticket.

I see you found a fix for the failing tests on your branch, congrats 🎉 In short I think both the approaches are valid.

The std::to_string approach relies on the current locale for formatting options (see cppref for more details). This works, but formatting of floats and doubles is not consistent across clients.

Since the tests in shortest_path_test.cpp are expecting error messages created with fmt::format, this results in failing assertions such as "Negative edge weight [-1.000000] between..." == "Negative edge weight [-1] between...". A fix would be to not create the expected error message using fmt, but rather use the same approach used as generating the error message (std::to_string(weight_t{-1})).

Using sstream is another approach, which is closer (if not equal) to what fmt uses under the hood. So with this approach the tests can keep using fmt.

I slightly favor the current approach as it allows us to use fmt in the test executables, making testing a bit more developer friendly.

@bobluppes bobluppes added the refactor A change which does not change any behavior label Aug 17, 2023
@bobluppes
Copy link
Owner

LGTM, congrats on the first real code contribution 🚀

@bobluppes bobluppes merged commit 093151f into bobluppes:main Aug 17, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor A change which does not change any behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants