HomePhabricator
Diffusion Comm 0eb7a828a7d8

[lib] Add some unit tests for `invertObjectToMap<K, V>(obj: { [K]: V })`

Description

[lib] Add some unit tests for invertObjectToMap<K, V>(obj: { [K]: V })

Summary:
Generated some basic unit tests for invertObjectToMap via GitHub Copilot.

One of the generated tests failed and surfaced possiblity that object entries could be "lost" if there were duplicate values... which is very often a possiblity. Added invariant to ensure values are unique and no entries are lost. Should be O(1) check so not worried about overhead.

Test Plan: Unit tests pass, made sure we had a test for BigInt values.

Reviewers: ashoat, ginsu, tomek, rohan

Reviewed By: ashoat

Subscribers: wyilio

Differential Revision: https://phab.comm.dev/D9677

Details

Provenance
atulAuthored on Nov 2 2023, 6:13 PM
Reviewer
ashoat
Differential Revision
D9677: [lib] Add some unit tests for `invertObjectToMap<K, V>(obj: { [K]: V })`
Parents
rCOMM7483cae752b2: [lib] Introduce `invertObjectToMap`
Branches
Unknown
Tags
Unknown