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

String Equality tests in tests/main.cpp #857

Open
zbud-msft opened this issue Feb 8, 2024 · 0 comments
Open

String Equality tests in tests/main.cpp #857

zbud-msft opened this issue Feb 8, 2024 · 0 comments

Comments

@zbud-msft
Copy link
Contributor

zbud-msft commented Feb 8, 2024

Currently in tests/main.cpp, we are testing corner cases with a few SonicDBConfig functions, and we test that the string from the exception that is caught, matches an expected string.

https://github.com/sonic-net/sonic-swss-common/blob/master/tests/main.cpp#L71

However, this is not robust and better practice would be to test for what exception type is thrown as exception strings can be easily changed breaking the test or having to change in multiple locations.

https://github.com/sonic-net/sonic-swss-common/blob/master/common/dbconnector.cpp#L248

Here we see out_of_range exception thrown; we can use EXPECT_THROW instead to test that the same exception is thrown in our UT.

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