Skip to content

Commit b460615

Browse files
committed
Initial commit
0 parents  commit b460615

File tree

10 files changed

+425
-0
lines changed

10 files changed

+425
-0
lines changed

.idea/leetcode_problems.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/watcherTasks.xml

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 217 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leetcode_problems

jewels_and_stones/jewels_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package jewels_and_stones
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
)
7+
8+
type TestCase struct {
9+
id int
10+
description string
11+
input Input
12+
expectedResult int
13+
}
14+
15+
type Input struct {
16+
jewels string
17+
stones string
18+
}
19+
20+
type TestSuite []TestCase
21+
22+
var ts = TestSuite{
23+
TestCase{
24+
id: 1,
25+
description: "One Jewel - lowercase",
26+
input: Input{
27+
jewels: "a",
28+
stones: "AzalkK",
29+
},
30+
expectedResult: 1,
31+
},
32+
TestCase{
33+
id: 2,
34+
description: "3 Jewels - lowercase + uppercase",
35+
input: Input{
36+
jewels: "aA",
37+
stones: "aAAbbbb",
38+
},
39+
expectedResult: 3,
40+
},
41+
TestCase{
42+
id: 3,
43+
description: "Empty Jewels",
44+
input: Input{
45+
jewels: "",
46+
stones: "aAAsdsdaK",
47+
},
48+
expectedResult: 0,
49+
},
50+
TestCase{
51+
id: 4,
52+
description: "Empty stones",
53+
input: Input{
54+
jewels: "aA",
55+
stones: "",
56+
},
57+
expectedResult: 0,
58+
},
59+
}
60+
61+
func TestJewels(t *testing.T) {
62+
63+
for _, tc := range ts {
64+
t.Run(fmt.Sprintf("Test%d", tc.id), func(t *testing.T) {
65+
66+
actualResult := numJewelsInStones(tc.input.jewels, tc.input.stones)
67+
68+
if actualResult != tc.expectedResult {
69+
fmt.Printf(" - Got: %d\n - Expected: %d\n", actualResult, tc.expectedResult)
70+
t.Fail()
71+
}
72+
73+
})
74+
}
75+
76+
}

0 commit comments

Comments
 (0)