test-case icon indicating copy to clipboard operation
test-case copied to clipboard

Uppercase and lowercase generated test function collide

Open ssipos90 opened this issue 3 years ago • 4 comments

Hello,

If you write tests like this, the generated function names will collide (_a_expects):

    #[test_case('a')]
    #[test_case('A')]
    fn test (_: char) {
    }

I worked around it by adding an extra argument in front:

    #[test_case(1, 'a')]
    #[test_case(2, 'A')]
    fn test (_: u32, _: char) {
    }

Maybe it would be easy to suffix the index of the test case to the generated name (_a_expects_{}).

Thanks.

ssipos90 avatar Dec 03 '22 10:12 ssipos90

For now in such cases we provide way to comment test cases. Comments replace usual test name generation. There's more info on wiki https://github.com/frondeus/test-case/wiki/Test-Names. There was a proposal to allow setting test names manually, but there wasn't enough need for that at the moment and it died, as comments suffice in most cases. As for indexing, maybe it would be nice to append them, but I need to sleep on the idea.

luke-biel avatar Dec 04 '22 18:12 luke-biel

The solution provided on #19 should resolve this problem, but I'm not sure about a scenario like:

    #[test_case('a')]
    #[test_case('a')]
    fn test (_: u32, _: char) {
    }

Should it be accepted? From a library perspective, I don't see a reason for us to block it, but it would make tracing a bit more difficult.

AugustoFKL avatar Jan 24 '24 03:01 AugustoFKL

Hmm in that particular case:

Two tests cases with the same name would be translated to two functions with the same name. And that would cause an error, right?

The question is - if the error message would be clear enough to the user of test case. If not then probably we should check the uniqueness in our side

On Wed, Jan 24, 2024, 04:36 Augusto Fotino @.***> wrote:

The solution provided on #19 https://github.com/frondeus/test-case/issues/19 should resolve this problem, but I'm not sure about a scenario like:

#[test_case('a')]
#[test_case('a')]
fn test (_: u32, _: char) {
}

Should it be accepted? From a library perspective, I don't see a reason for us to block it, but it would make tracing a bit more difficult.

— Reply to this email directly, view it on GitHub https://github.com/frondeus/test-case/issues/108#issuecomment-1907299113, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI4UANBUEQA66CWEPWUV4DYQB6TTAVCNFSM6AAAAAASSVKG42VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBXGI4TSMJRGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

frondeus avatar Jan 24 '24 11:01 frondeus

I see

I am studying a way to refine the proposal I did on #19, but if we are considering that tests with the same name shouild not be accepted, then it makes things easier.

AugustoFKL avatar Jan 24 '24 18:01 AugustoFKL