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)
Fri, Dec 20, 12:28 AM
Unknown Object (File)
Sat, Nov 30, 6:53 PM
Unknown Object (File)
Sat, Nov 30, 11:49 AM
Unknown Object (File)
Nov 16 2024, 8:54 PM
Unknown Object (File)
Nov 16 2024, 8:54 PM
Unknown Object (File)
Nov 16 2024, 8:54 PM
Unknown Object (File)
Nov 16 2024, 8:54 PM
Unknown Object (File)
Nov 16 2024, 8:53 PM
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable