mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
Added BinaryToHex Conversion
This commit is contained in:
19
Conversions/test/BinaryToHex.test.js
Normal file
19
Conversions/test/BinaryToHex.test.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import binaryToHex from '../BinaryToHex'
|
||||
|
||||
describe('BinaryToHex', () => {
|
||||
it('expects to return correct hexadecimal value', () => {
|
||||
expect(binaryToHex('1000')).toBe('8')
|
||||
})
|
||||
|
||||
it('expects to return correct hexadecimal value for more than one hex digit', () => {
|
||||
expect(binaryToHex('11101010')).toBe('EA')
|
||||
})
|
||||
|
||||
it('expects to return correct hexadecimal value for padding-required binary', () => {
|
||||
expect(binaryToHex('1001101')).toBe('4D')
|
||||
})
|
||||
|
||||
it('expects to return correct hexadecimal value, matching (num).toString(16)', () => {
|
||||
expect(binaryToHex('1111')).toBe(parseInt('1111', 2).toString(16).toUpperCase())
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user