Skip to content

Commit 1992425

Browse files
authored
merge: Add test cases to ArbitraryBase, DateToDay & DateDayDifference Algorithm (#929)
1 parent a545f76 commit 1992425

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { convertArbitraryBase } from '../ArbitraryBase'
2+
3+
test('Check the answer of convertArbitraryBase(98, 0123456789, 01234567) is 142', () => {
4+
const res = convertArbitraryBase('98', '0123456789', '01234567')
5+
expect(res).toBe('142')
6+
})
7+
8+
test('Check the answer of convertArbitraryBase(98, 0123456789, abcdefgh) is bec', () => {
9+
const res = convertArbitraryBase('98', '0123456789', 'abcdefgh')
10+
expect(res).toBe('bec')
11+
})
12+
13+
test('Check the answer of convertArbitraryBase(98, 0123456789, 98765432) is 857', () => {
14+
const res = convertArbitraryBase('98', '0123456789', '98765432')
15+
expect(res).toBe('857')
16+
})
17+
18+
test('Check the answer of convertArbitraryBase(129, 0123456789, 01234567) is 201', () => {
19+
const res = convertArbitraryBase('129', '0123456789', '01234567')
20+
expect(res).toBe('201')
21+
})
22+
23+
test('Check the answer of convertArbitraryBase(112, 0123456789, 12345678) is 271', () => {
24+
const res = convertArbitraryBase('112', '0123456789', '12345678')
25+
expect(res).toBe('271')
26+
})
27+
28+
test('Check the answer of convertArbitraryBase(112, 0123456789, 123456789) is 245', () => {
29+
const res = convertArbitraryBase('112', '0123456789', '123456789')
30+
expect(res).toBe('245')
31+
})
32+
33+
test('Check the answer of convertArbitraryBase(111, 0123456789, abcdefgh) is bfh', () => {
34+
const res = convertArbitraryBase('111', '0123456789', 'abcdefgh')
35+
expect(res).toBe('bfh')
36+
})
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { DateDayDifference } from '../DateDayDifference'
2+
3+
test('The difference between 17/08/2002 & 10/10/2020 is 6630', () => {
4+
const res = DateDayDifference('17/08/2002', '10/10/2020')
5+
expect(res).toBe(6630)
6+
})
7+
8+
test('The difference between 18/02/2001 & 16/03/2022 is 7696', () => {
9+
const res = DateDayDifference('18/02/2001', '16/03/2022')
10+
expect(res).toBe(7696)
11+
})
12+
13+
test('The difference between 11/11/2011 & 12/12/2012 is 398', () => {
14+
const res = DateDayDifference('11/11/2011', '12/12/2012')
15+
expect(res).toBe(398)
16+
})
17+
18+
test('The difference between 01/01/2001 & 16/03/2011 is 3727', () => {
19+
const res = DateDayDifference('01/01/2001', '16/03/2011')
20+
expect(res).toBe(3727)
21+
})

Conversions/test/DateToDay.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { DateToDay } from '../DateToDay'
2+
3+
test('The date 18/02/2001 is Monday', () => {
4+
const res = DateToDay('18/02/2001')
5+
expect(res).toBe('Monday')
6+
})
7+
8+
test('The date 18/12/2020 is Friday', () => {
9+
const res = DateToDay('18/12/2020')
10+
expect(res).toBe('Friday')
11+
})
12+
13+
test('The date 12/12/2012 is Wednesday', () => {
14+
const res = DateToDay('12/12/2012')
15+
expect(res).toBe('Wednesday')
16+
})
17+
test('The date 01/01/2001 is Friday', () => {
18+
const res = DateToDay('01/01/2001')
19+
expect(res).toBe('Friday')
20+
})

0 commit comments

Comments
 (0)