mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-12-19 06:58:15 +08:00
fix: added reverse string inplace (#1406)
Co-authored-by: madhuredra <madhuredra.tiwari@zemosolabs.com>
This commit is contained in:
committed by
GitHub
parent
36dcff8c5d
commit
0ca18c2b2c
@@ -35,31 +35,10 @@ describe('ReverseStringIterative', () => {
|
||||
})
|
||||
|
||||
describe('ReverseStringIterativeInplace', () => {
|
||||
it('expects to reverse a simple string', () => {
|
||||
expect(ReverseStringIterativeInplace('reverse')).toEqual('esrever')
|
||||
expect(ReverseStringIterativeInplace('some')).toEqual('emos')
|
||||
expect(ReverseStringIterativeInplace('string')).toEqual('gnirts')
|
||||
expect(ReverseStringIterativeInplace('The Algorithms Javascript')).toEqual('tpircsavaJ smhtiroglA ehT')
|
||||
it.each([
|
||||
['hello', 'olleh'],
|
||||
['word', 'drow']
|
||||
])('reverse of %s is %s', (value, expected) => {
|
||||
expect(ReverseStringIterativeInplace(value)).toBe(expected)
|
||||
})
|
||||
|
||||
it('expects to reverse a simple string without capitalizing the first letter', () => {
|
||||
expect(ReverseStringIterativeInplace('Javascript')).toEqual('tpircsavaJ')
|
||||
})
|
||||
|
||||
it('expects to return an empty string given an empty string', () => {
|
||||
expect(ReverseStringIterativeInplace('Javascript')).toEqual('tpircsavaJ')
|
||||
})
|
||||
|
||||
it.each`
|
||||
input
|
||||
${123456}
|
||||
${[1, 2, 3, 4, 5, 6]}
|
||||
${{ test: 'test' }}
|
||||
${null}
|
||||
`(
|
||||
'expects to throw a type error given a value that is $input',
|
||||
({ input }) => {
|
||||
expect(() => ReverseStringIterativeInplace(input)).toThrow('The given value is not a string')
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user