Read fixed size strings without padding characters#692
Read fixed size strings without padding characters#692FlyingSamson wants to merge 5 commits intoess-dmsc:masterfrom
Conversation
|
|
||
| AND_GIVEN("an instance of a smaller string") { | ||
| std::string write = "hell"; | ||
| THEN("we have to resize the string to the appropriate size") { |
There was a problem hiding this comment.
Not entirely sure, why this was required in the first place.
From what I understand the code will write shorter strings just fine. This line merely ensured that in the REQUIRE_THAT below write also contained trailing \0 characters.
|
I don't quite have the mental capacity to deal with this on a Friday evening, but I would refer you to my comments on a different PR: ess-dmsc/streaming-data-types#102 (comment)
Surely if it's like to be a different length wouldn't it be better to use |
This would be one way to overcome the current issue that when reading fixed-size strings into
std::strings all padding characters are also returned.This will certainly introduce a certain overhead compared to not trimming the read string (I did not perform any benchmarks though) which need to be contemplated.
On the other hand, in cases where the caller actually wants the trimmed string, forcing him to trim the string himself after it has been created might incur even larger costs.
Resolves #661
Also relevant for #215 and #224