-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<random>: Fixes subtract_with_carry_engine io
#2088
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
Merged
Casey Carter (CaseyCarter)
merged 3 commits into
microsoft:main
from
yuanhongzhao:gh-442
Oct 9, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/std/tests/GH_000442_random_subtract_with_carry_engine_io/env.lst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| RUNALL_INCLUDE ..\usual_matrix.lst |
80 changes: 80 additions & 0 deletions
80
tests/std/tests/GH_000442_random_subtract_with_carry_engine_io/test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include <cassert> | ||
| #include <cstddef> | ||
| #include <ios> | ||
| #include <random> | ||
| #include <sstream> | ||
| #include <string> | ||
| using namespace std; | ||
|
|
||
| void check_state(const string& state_str) { | ||
| // Check word-by-word in case of whitespace differences. | ||
| static constexpr const char* state_ref[] = { | ||
| "10880375256626", | ||
| "126660097854724", | ||
| "33643165434010", | ||
| "78293780235492", | ||
| "179418984296008", | ||
| "96783156950859", | ||
| "238199764491708", | ||
| "34339434557790", | ||
| "155299155394531", | ||
| "29014415493780", | ||
| "209265474179052", | ||
| "263777435457028", | ||
| "0", | ||
| }; | ||
| constexpr auto state_size = size(state_ref); | ||
| stringstream sstr(state_str); | ||
|
|
||
| size_t idx = 0; | ||
| string word; | ||
| while (sstr && idx < state_size) { | ||
| sstr >> word; | ||
| assert(word == state_ref[idx]); | ||
| ++idx; | ||
| } | ||
|
|
||
| assert(sstr.rdstate() == ios_base::eofbit); | ||
| assert(idx == state_size); | ||
| } | ||
|
|
||
| void check(stringstream& sstr) { | ||
| // N4892 [tab:rand.req.eng]: "Postconditions: The os.fmtflags and fill character are unchanged." | ||
| // and "Postconditions: The is.fmtflags are unchanged." | ||
| const auto old_flags = sstr.flags(); | ||
| const auto old_fill = sstr.fill(); | ||
| ranlux48_base eng1; | ||
| ranlux48_base eng2; | ||
| sstr << eng1; | ||
| check_state(sstr.str()); | ||
| sstr >> eng2; | ||
| assert(eng1 == eng2); | ||
| assert(sstr.flags() == old_flags); | ||
| assert(sstr.fill() == old_fill); | ||
| } | ||
|
|
||
| int main() { | ||
| { | ||
| stringstream sstr; | ||
| sstr << hex; | ||
| check(sstr); | ||
| } | ||
|
|
||
| { | ||
| stringstream sstr; | ||
| sstr.unsetf(ios_base::skipws); | ||
| check(sstr); | ||
| } | ||
|
|
||
| { | ||
| stringstream sstr; | ||
| sstr.fill('.'); | ||
| sstr.width(40); | ||
| check(sstr); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for other reviewers (no change requested): as the runtime behavior here was completely messed up, I am okay with changing the serialized output.