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

Add standard constraints to classes #7

Open
tudortimi opened this issue Sep 9, 2022 · 0 comments
Open

Add standard constraints to classes #7

tudortimi opened this issue Sep 9, 2022 · 0 comments

Comments

@tudortimi
Copy link
Owner

It is often very useful to constraint fields of classes to be equal to a value or in a certain range, as well as the opposites of the previous two. These can be provided by the library:

class some_class;

  rand int some_int_field;
  rand some_enum_e some_enum_field;

  `constraints_infrastructure_begin(some_class)
    `constraints_field(int, some_field)
    `constraints_field(some_enum_e, some_enum_field)
  `constraints_infrastructure_end

endclass

This would define the following factory methods:

some_class::standard_constraints::on_some_int_field::only(10);
some_class::standard_constraints::on_some_int_field::never(42);
some_class::standard_constraints::on_some_int_field::any_of('{  1, 10, 100 });
some_class::standard_constraints::on_some_int_field::none_of('{  -1, -10, -100 });

and the same for some_enum_field.

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

No branches or pull requests

1 participant