Skip to content

String Equality tests in tests/main.cpp #857

@zbud-msft

Description

@zbud-msft

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions