Skip to content

Commit

Permalink
chore: add some radio utils tests (flybywiresim#9389)
Browse files Browse the repository at this point in the history
  • Loading branch information
tracernz authored Nov 4, 2024
1 parent 49dc4bc commit a449f14
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fbw-common/src/systems/shared/src/RadioUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('RadioUtils.unpackVhfComFrequencyFromArincToHz', () => {
it('correctly unpacks arinc BCD to Hz', () => {
expect(RadioUtils.unpackVhfComFrequencyFromArincToHz(0x18_500)).toBe(118_500_000);
expect(RadioUtils.unpackVhfComFrequencyFromArincToHz(0x22_250)).toBe(122_250_000);
expect(RadioUtils.unpackVhfComFrequencyFromArincToHz(0x26_425)).toBe(126_425_000);
expect(RadioUtils.unpackVhfComFrequencyFromArincToHz(0x36_975)).toBe(136_975_000);
});
});
Expand All @@ -48,10 +49,20 @@ describe('RadioUtils.packBcd32VhfComFrequencyToArinc', () => {
it('correctly translates to ARINC VHF COM format', () => {
expect(RadioUtils.packBcd32VhfComFrequencyToArinc(0x118_500_0)).toBe(0x18_500);
expect(RadioUtils.packBcd32VhfComFrequencyToArinc(0x122_250_0)).toBe(0x22_250);
expect(RadioUtils.packBcd32VhfComFrequencyToArinc(0x126_425_0)).toBe(0x26_425);
expect(RadioUtils.packBcd32VhfComFrequencyToArinc(0x136_975_0)).toBe(0x36_975);
});
});

describe('RadioUtils.packVhfComFrequencyToArinc', () => {
it('correctly translates to ARINC VHF COM format', () => {
expect(RadioUtils.packVhfComFrequencyToArinc(118_500_000)).toBe(0x18_500);
expect(RadioUtils.packVhfComFrequencyToArinc(122_250_000)).toBe(0x22_250);
expect(RadioUtils.packVhfComFrequencyToArinc(126_425_000)).toBe(0x26_425);
expect(RadioUtils.packVhfComFrequencyToArinc(136_975_000)).toBe(0x36_975);
});
});

describe('RadioUtils.packBcd16VhfComFrequencyToArinc', () => {
it('correctly translates to ARINC VHF COM format', () => {
expect(RadioUtils.packBcd16VhfComFrequencyToArinc(0x1850)).toBe(0x18_500);
Expand All @@ -65,6 +76,7 @@ describe('RadioUtils.unpackVhfComFrequencyFromArincToBcd32', () => {
it('correctly translates from ARINC VHF COM format', () => {
expect(RadioUtils.unpackVhfComFrequencyFromArincToBcd32(0x18_500)).toBe(0x118_500_0);
expect(RadioUtils.unpackVhfComFrequencyFromArincToBcd32(0x22_250)).toBe(0x122_250_0);
expect(RadioUtils.unpackVhfComFrequencyFromArincToBcd32(0x26_425)).toBe(0x126_425_0);
expect(RadioUtils.unpackVhfComFrequencyFromArincToBcd32(0x36_975)).toBe(0x136_975_0);
});
});
Expand Down

0 comments on commit a449f14

Please sign in to comment.