-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
AnyParameterProperties tests #4414
Changes from 10 commits
9bc6414
00dcc2f
e296c3f
b1fb379
02298ad
d94653f
64668b5
462492a
1188b86
fdb2d01
28d5d6e
cd7aa44
e202eb9
5e2255d
896f0a8
caf1798
722e46c
b601b90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,3 +691,69 @@ TEST(Any, lazy_cloneable_visitable) | |
EXPECT_FALSE(any.visitable()); | ||
EXPECT_THROW(any.visit(nullptr), std::logic_error); | ||
} | ||
|
||
TEST(AnyParameterProperties, old_api_default) | ||
{ | ||
AnyParameterProperties params = AnyParameterProperties(); | ||
|
||
EXPECT_EQ(params.get_description(), "No description given"); | ||
EXPECT_EQ( | ||
params.get_model_selection(), | ||
EModelSelectionAvailability::MS_NOT_AVAILABLE); | ||
EXPECT_EQ( | ||
params.get_gradient(), EGradientAvailability::GRADIENT_NOT_AVAILABLE); | ||
EXPECT_FALSE(params.get_model()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get model is not part of the old API or? Just realising this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't, but the constructor of the old API still sets the ParameterProperties::MODEL bit, so I just thought it would be appropriate to add this check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would be covered in the test below where we check that nothing is set after construction. |
||
} | ||
|
||
TEST(AnyParameterProperties, new_api_default) | ||
{ | ||
AnyParameterProperties params = AnyParameterProperties(); | ||
|
||
EXPECT_EQ(params.get_description(), "No description given"); | ||
gf712 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
EXPECT_FALSE(params.is_property( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imagine we get more properties ... this test then needs to be touched which makes maintenance noisy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK! So you mean have three tests, one for each parameter? The only thing that feels like is missing is an enum for zero, since we can't compare the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well I guess 0 and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just write a test that ensures that the default parameter properties are 0 |
||
ParameterProperties::MODEL | ParameterProperties::GRADIENT | | ||
ParameterProperties::HYPER)); | ||
} | ||
|
||
TEST(AnyParameterProperties, old_custom_ctor) | ||
{ | ||
AnyParameterProperties params = AnyParameterProperties( | ||
"test", EModelSelectionAvailability::MS_NOT_AVAILABLE, | ||
EGradientAvailability::GRADIENT_AVAILABLE, true); | ||
|
||
EXPECT_EQ(params.get_description(), "test"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep here we can/should test |
||
EXPECT_EQ( | ||
params.get_model_selection(), | ||
EModelSelectionAvailability::MS_NOT_AVAILABLE); | ||
EXPECT_EQ(params.get_gradient(), EGradientAvailability::GRADIENT_AVAILABLE); | ||
EXPECT_TRUE(params.get_model()); | ||
|
||
EXPECT_TRUE(params.is_property( | ||
ParameterProperties::MODEL | ParameterProperties::GRADIENT)); | ||
EXPECT_FALSE(params.is_property( | ||
ParameterProperties::HYPER & ParameterProperties::GRADIENT)); | ||
EXPECT_TRUE(params.is_property( | ||
~ParameterProperties::HYPER & ParameterProperties::GRADIENT)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesnt make sense. You cannot check that a property is not set using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, I found it a bit odd when I wrote it. It seems unnecessarily convoluted... |
||
EXPECT_FALSE(params.is_property(ParameterProperties::HYPER)); | ||
} | ||
|
||
TEST(AnyParameterProperties, new_custom_ctor) | ||
{ | ||
AnyParameterProperties params = AnyParameterProperties( | ||
"test", ParameterProperties::MODEL | ParameterProperties::GRADIENT); | ||
|
||
EXPECT_EQ(params.get_description(), "test"); | ||
EXPECT_EQ( | ||
params.get_model_selection(), | ||
EModelSelectionAvailability::MS_NOT_AVAILABLE); | ||
EXPECT_EQ(params.get_gradient(), EGradientAvailability::GRADIENT_AVAILABLE); | ||
EXPECT_TRUE(params.get_model()); | ||
|
||
EXPECT_TRUE(params.is_property( | ||
ParameterProperties::MODEL | ParameterProperties::GRADIENT)); | ||
EXPECT_FALSE(params.is_property( | ||
ParameterProperties::HYPER & ParameterProperties::GRADIENT)); | ||
EXPECT_TRUE(params.is_property( | ||
~ParameterProperties::HYPER & ParameterProperties::GRADIENT)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above |
||
EXPECT_FALSE(params.is_property(ParameterProperties::HYPER)); | ||
} |
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.
I would name it
has_property