Skip to content

Alter testutuil::*Doc to return shared_ptrs. #2546

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
merged 8 commits into from
Mar 25, 2019

Conversation

rsgowman
Copy link
Member

No description provided.

@rsgowman rsgowman self-assigned this Mar 13, 2019
@rsgowman
Copy link
Member Author

Summary: The mutations require shared_ptrs, everything else does not. This sets up an awkward split between mutation_test.cc and everythingelse_test.cc. But it may still be worth it.

For the everythingelse case, there's two approaches we could take:

  1. Just dereference the pointer, creating a copy. Slightly inefficient, but it's the test suite, so who cares? The cost of this PR would then be just an extra *. Example: query_test.cc
  2. Use shared_ptrs in the test too. No wrap and then immediately unwrap, but more verbose. Ex: precondition_test.cc

We should settle on one of those two before submitting.

Copy link
Contributor

@var-const var-const left a comment

Choose a reason for hiding this comment

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

I didn't realize how many Documents and related classes were used by value, but it seems like adding all those dereferences might still be the lesser of two evils.

const Document doc = testutil::Doc("bar/doc", 7654321);
EXPECT_TRUE(none.IsValidFor(&deleted_doc));
EXPECT_TRUE(none.IsValidFor(&doc));
const std::shared_ptr<NoDocument> deleted_doc =
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: there was previously an agreement to avoid const values, so consider omitting those consts. Entirely optional, because they weren't added in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done throughout this file. I've not attempted to apply this more broadly though.

@var-const var-const assigned rsgowman and unassigned var-const Mar 18, 2019
@rsgowman rsgowman merged commit 8e37cfe into master Mar 25, 2019
@rsgowman rsgowman deleted the rsgowman/mutation_test_fixups branch March 25, 2019 20:41
@firebase firebase locked and limited conversation to collaborators Oct 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants