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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding a variant which inverses the declaration by being case by case #29

Open
foresterre opened this issue Apr 29, 2020 · 0 comments

Comments

@foresterre
Copy link
Owner

foresterre commented Apr 29, 2020

Current:

    #[parameterized(
        text = {
            "aaa",
            "bab",
            "馃槂bc"
        },
        expected = {
            'a',
            'b',
            '馃槂'
        }
    )]
    fn test_peek_first_chars(text: &str, expected: char) {
        assert_eq!(text.peek_first(), expected);
    }

declared case by case:

    #[parameterized'(
        triple_a = {
            "aaa",
            'a',
       },
       bab = {
            "bab",
            'b',
        },
        emoji = {
            text: "馃槂ab", // optionally named, but original order should be preserved for consistency
            expected: '馃槂'
        }
    )]
    fn test_peek_first_chars(text: &str, expected: char) {
        assert_eq!(text.peek_first(), expected);
    }

Advantages

  • trivial to define test case naming
  • potentially declaring a lot of test argument identifiers on test case declaration (that's why making them optional is a good idea I think)

Disadvantages:

  • similar test case data spread out more
  • potentially huge attribute declarations, with nesting which makes it potentially harder to read
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