Page MenuHomePhabricator

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

Authored by atul on Nov 2 2023, 11:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 8:54 PM
Unknown Object (File)
Sat, Nov 16, 8:54 PM
Unknown Object (File)
Sat, Nov 16, 8:54 PM
Unknown Object (File)
Sat, Nov 16, 8:54 PM
Unknown Object (File)
Sat, Nov 16, 8:53 PM
Unknown Object (File)
Thu, Nov 14, 9:03 PM
Unknown Object (File)
Oct 15 2024, 1:37 AM
Unknown Object (File)
Oct 15 2024, 1:37 AM
Subscribers

Details

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.

Diff Detail

Repository
rCOMM Comm
Branch
arcpatch-D9677 (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage