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

Ensure default mock names are (more) unique #359

Merged
merged 1 commit into from
Jun 5, 2017

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Jun 5, 2017

Default mock object names are built from the type name and a hex number. Instead of building that number from the first 4 digits of a GUID — a whole GUID is in practice unique, but the same does not hold true for only 4 of its digits —, create 8 unique (but non-random) hex digits in the simplest possible way: using a thread-safe ever-increasing counter.

It is still possible that the same number is used more than once, but this is now far less likely to happen in real-world scenarios: it would require the generation of more than 232 mock objects.

This fixes #348.

Default mock object names are built from the type name and a hex
number. Instead of building that number from the first 4 digits of a
GUID, create 8 unique (but non-random) hex digits in the simplest
possible way: using a thread-safe ever-increasing counter.

It is still possible that the same number is used more than once, but
this is now far less likely to happen in real-world scenarios: it
would require the generation of more than 2^32 mock objects.
@kzu kzu merged commit 32897e1 into devlooped:develop Jun 5, 2017
@stakx stakx deleted the unique-mock-names branch June 5, 2017 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants