File tree Expand file tree Collapse file tree 2 files changed +61
-55
lines changed
src/hackerrank/interview_preparation_kit/string_manipulation Expand file tree Collapse file tree 2 files changed +61
-55
lines changed Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "title" : " Sample Test case 0" ,
4
+ "tests" : [
5
+ {
6
+ "input" : " AAAA" ,
7
+ "expected" : 3
8
+ },
9
+ {
10
+ "input" : " BBBBB" ,
11
+ "expected" : 4
12
+ },
13
+ {
14
+ "input" : " ABABABAB" ,
15
+ "expected" : 0
16
+ },
17
+ {
18
+ "input" : " BABABA" ,
19
+ "expected" : 0
20
+ },
21
+ {
22
+ "input" : " AAABBB" ,
23
+ "expected" : 4
24
+ }
25
+ ]
26
+ },
27
+ {
28
+ "title" : " Sample Test case 13" ,
29
+ "tests" : [
30
+ {
31
+ "input" : " AAABBBAABB" ,
32
+ "expected" : 6
33
+ },
34
+ {
35
+ "input" : " AABBAABB" ,
36
+ "expected" : 4
37
+ },
38
+ {
39
+ "input" : " ABABABAA" ,
40
+ "expected" : 1
41
+ }
42
+ ]
43
+ },
44
+ {
45
+ "title" : " Sample Test case 14" ,
46
+ "tests" : [
47
+ {
48
+ "input" : " ABBABBAA" ,
49
+ "expected" : 3
50
+ }
51
+ ]
52
+ }
53
+ ]
Original file line number Diff line number Diff line change 1
1
import unittest
2
+ from pathlib import Path
3
+
4
+ from ....hackerrank .lib .loader import load_test_cases
2
5
from .alternating_characters import alternating_characters
3
6
4
- TEST_CASES = [
5
- {
6
- 'title' : 'Sample Test case 0' ,
7
- 'tests' : [
8
- {
9
- 'input' : 'AAAA' ,
10
- 'answer' : 3
11
- },
12
- {
13
- 'input' : 'BBBBB' ,
14
- 'answer' : 4
15
- },
16
- {
17
- 'input' : 'ABABABAB' ,
18
- 'answer' : 0
19
- },
20
- {
21
- 'input' : 'BABABA' ,
22
- 'answer' : 0
23
- },
24
- {
25
- 'input' : 'AAABBB' ,
26
- 'answer' : 4
27
- }
28
- ]
29
- },
30
- {
31
- 'title' : 'Sample Test case 13' ,
32
- 'tests' : [
33
- {
34
- 'input' : 'AAABBBAABB' ,
35
- 'answer' : 6
36
- },
37
- {
38
- 'input' : 'AABBAABB' ,
39
- 'answer' : 4
40
- },
41
- {
42
- 'input' : 'ABABABAA' ,
43
- 'answer' : 1
44
- }
45
- ]
46
- },
47
- {
48
- 'title' : 'Sample Test case 14' ,
49
- 'tests' : [
50
- {
51
- 'input' : 'ABBABBAA' ,
52
- 'answer' : 3
53
- }
54
- ]
55
- }
56
- ]
7
+ FILE_PATH = str (Path (__file__ ).resolve ().parent )
8
+
9
+ TEST_CASES = load_test_cases (FILE_PATH + '/alternating_characters.testcases.json' )
57
10
58
11
59
12
class TestAlternatingCharacters (unittest .TestCase ):
@@ -65,6 +18,6 @@ def test_alternating_characters(self):
65
18
for _ , _tt in enumerate (testset ['tests' ]):
66
19
67
20
self .assertEqual (
68
- alternating_characters (_tt ['input' ]), _tt ['answer ' ],
21
+ alternating_characters (_tt ['input' ]), _tt ['expected ' ],
69
22
f"{ _ } | alternating_characters({ _tt ['input' ]} ) must be "
70
- f"=> { _tt ['answer ' ]} " )
23
+ f"=> { _tt ['expected ' ]} " )
You can’t perform that action at this time.
0 commit comments