general: Added tests
This commit is contained in:
parent
b16ff8bc4d
commit
fbc029b1b1
3 changed files with 48 additions and 1 deletions
2
neofetch
2
neofetch
|
@ -8724,4 +8724,4 @@ main() {
|
|||
return 0
|
||||
}
|
||||
|
||||
main "$@"
|
||||
[[ "$0" == "${BASH_SOURCE[0]}" ]] && main "$@"
|
||||
|
|
37
tests/test_misc.sh
Executable file
37
tests/test_misc.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Test misc functions.
|
||||
|
||||
source test_util.sh
|
||||
source ../neofetch
|
||||
|
||||
# Tests only work on Linux for now.
|
||||
os="Linux"
|
||||
|
||||
|
||||
test_convert_time() {
|
||||
# 24 hour time.
|
||||
result="$(convert_time "2016" "04" "14" "23:50")"
|
||||
assert_equals "$result" "Thu 14 Apr 2016 23:50"
|
||||
|
||||
# 12 hour time.
|
||||
install_time_format="12h"
|
||||
result="$(convert_time "2016" "04" "14" "23:50")"
|
||||
assert_equals "$result" "Thu 14 Apr 2016 11:50 PM"
|
||||
}
|
||||
|
||||
test_get_ppid() {
|
||||
result="$(trim "$(get_ppid "1")")"
|
||||
assert_equals "$result" "0"
|
||||
}
|
||||
|
||||
test_get_process_name() {
|
||||
result="$(get_process_name "1")"
|
||||
assert_equals "$result" "systemd"
|
||||
}
|
||||
|
||||
|
||||
printf "%s\\n" "Test MISC functions."
|
||||
test_convert_time
|
||||
test_get_ppid
|
||||
test_get_process_name
|
10
tests/test_util.sh
Normal file
10
tests/test_util.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Test util functions.
|
||||
|
||||
assert_equals() {
|
||||
# Test equality.
|
||||
local status
|
||||
[[ "$1" == "$2" ]] && status="✔"
|
||||
printf "%s\\n" " ${status:-✖} : ${FUNCNAME[1]}"
|
||||
}
|
Loading…
Reference in a new issue