-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_container_example.sh
More file actions
executable file
·64 lines (54 loc) · 2 KB
/
test_container_example.sh
File metadata and controls
executable file
·64 lines (54 loc) · 2 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
61
62
63
64
#!/usr/bin/env bats
VERSION_REGEX='^libClaPP\ v.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} [a-zA-Z]+\-Build: '
CLAPP_EXCEPTION_REGEX='^Caught\ ClaPP-Exception:.*$'
@test "container-example: no arguments/options given throws" {
run ./libclapp_example_container
[ "$status" -eq 1 ]
[[ "${lines[0]}" =~ $CLAPP_EXCEPTION_REGEX ]]
}
@test "container-example: show help with long option --help" {
run ./libclapp_example_container --help
[ "$status" -eq 0 ]
[ "${lines[0]}" = "Usage:" ]
}
@test "container-example: show help with short option -h" {
run ./libclapp_example_container -h
[ "$status" -eq 0 ]
[ "${lines[0]}" = "Usage:" ]
}
@test "container-example: show version with long option --version" {
run ./libclapp_example_container --version
[ "$status" -eq 0 ]
[[ "${lines[0]}" =~ $VERSION_REGEX ]]
}
@test "container-example: give mandatory options and u32" {
run ./libclapp_example_container --string str --u32 15
[ "$status" -eq 0 ]
[ "${lines[0]}" = "verbose: not given" ]
[ "${lines[1]}" = "string-param: str" ]
[ "${lines[2]}" = "uint32-param: 15" ]
}
@test "container-example: give mandatory options and i32" {
run ./libclapp_example_container -s string --i32 8
[ "$status" -eq 0 ]
[ "${lines[0]}" = "verbose: not given" ]
[ "${lines[1]}" = "string-param: string" ]
[ "${lines[2]}" = "int32-param: 8" ]
}
@test "container-example: give mandatory options i32 and verbose" {
run ./libclapp_example_container -s string --i32 17 --verbose -v
[ "$status" -eq 0 ]
[ "${lines[0]}" = "verbose: 4" ]
[ "${lines[1]}" = "string-param: string" ]
[ "${lines[2]}" = "int32-param: 17" ]
}
@test "container-example: missing int-options throw" {
run ./libclapp_example_container -s string
[ "$status" -eq 1 ]
[[ "${lines[0]}" =~ $CLAPP_EXCEPTION_REGEX ]]
}
@test "container-example: missing string-option throws" {
run ./libclapp_example_container --i32 17
[ "$status" -eq 1 ]
[[ "${lines[0]}" =~ $CLAPP_EXCEPTION_REGEX ]]
}