-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.spec.scad
More file actions
60 lines (56 loc) · 1.3 KB
/
Copy pathstring.spec.scad
File metadata and controls
60 lines (56 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
include <string.scad>
include <test.scad>
echo(describe("string.scad", [
describe("str_join", [
it("joins a list of strings with no separator", expect(
str_join(["a", "b", "c"]),
"abc"
)),
it("joins a list of strings with a dash separator", expect(
str_join(["a", "b", "c"], "-"),
"a-b-c"
)),
it("joins a single-element list", expect(
str_join(["x"]),
"x"
)),
it("joins an empty list", expect(
str_join([]),
""
)),
it("joins a non-list input", expect(
str_join("z"),
"z"
)),
it("joins numbers as strings", expect(
str_join([1, 2, 3], ", "),
"1, 2, 3"
))
]),
describe("str_count_char", [
it("counts one character match", expect(
str_count_char("abc", "a"),
1
)),
it("counts multiple character matches", expect(
str_count_char("banana", "a"),
3
)),
it("counts zero matches", expect(
str_count_char("hello", "z"),
0
)),
it("counts characters in an empty string", expect(
str_count_char("", "a"),
0
)),
it("counts with a character not in string", expect(
str_count_char("123123", "4"),
0
)),
it("counts numeric characters", expect(
str_count_char("1223334444", "4"),
4
))
])
]));