Custom-set: new test against deduplication

There is one test for deduplication in custom-set. (Here’s the forum post for adding that one.) It looks like this:

{
  "uuid": "d4a1142f-09aa-4df9-8b83-4437dcf7ec24",
  "description": "set is equal to a set constructed from an array with duplicates",
  "property": "equal",
  "input": {
    "set1": [1],
    "set2": [1, 1]
  },
  "expected": true
}

This still allows an internal representation that contains duplicates. It only ensures that the custom equlity check ignores potential duplicates. This is fine, we don’t want to enforce some specific internal representation.

But there is another easy mistake that can happen with duplicates. Here’s the new test I’m proposing:

{
  "property": "difference",
  "input": {
    "set1": [1, 1],
    "set2": [1]
  },
  "expected": []
}

When taking the difference of these two sets, an easy mistake is to remove “1” only once from the internal representation. The result would then still contain the second “1” and not be equal to the expected empty set.

Do you think this is a valuable test to add to problem-specifications?

The idea for this test case is from this post in the Rust category.

I think this could make sense, yes!

1 Like

link to PR