Skip to content

Commit 388b82e

Browse files
committed
Add additional test cases for countChar function to cover case sensitivity
1 parent 6da58b9 commit 388b82e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Sprint-3/2-practice-tdd/count.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,38 @@ test("should return 0 when character does not exist in the string", () => {
2929
const count = countChar(str, char);
3030
expect(count).toEqual(0);
3131
});
32+
33+
test("should be case sensitive and only count exact character matches", () => {
34+
const str = "AaAaAa";
35+
const char = "a";
36+
const count = countChar(str, char);
37+
expect(count).toEqual(3);
38+
});
39+
40+
test("should be case sensitive - uppercase A should not match lowercase a", () => {
41+
const str = "AaAaAa";
42+
const char = "A";
43+
const count = countChar(str, char);
44+
expect(count).toEqual(3);
45+
});
46+
47+
test("should count occurrences of numeric characters", () => {
48+
const str = "1a2b3c1d2e1f";
49+
const char = "1";
50+
const count = countChar(str, char);
51+
expect(count).toEqual(3);
52+
});
53+
54+
test("should count occurrences of special characters", () => {
55+
const str = "hello!world!test!";
56+
const char = "!";
57+
const count = countChar(str, char);
58+
expect(count).toEqual(3);
59+
});
60+
61+
test("should count occurrences of spaces", () => {
62+
const str = "hello world this is a test";
63+
const char = " ";
64+
const count = countChar(str, char);
65+
expect(count).toEqual(5);
66+
});

0 commit comments

Comments
 (0)