Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- `clock::now` handles `EPOCHREALTIME` values that use a comma decimal separator
- Invalid `.env.example` coverage threshold entry; CI now copies `.env.example` to `.env` so config parse errors are caught
- Coverage no longer counts case patterns with trailing comments (e.g. `*thing) # note`) or loop terminators with redirections/pipes (e.g. `done < file`, `done <<<"$var"`, `done | sort`) as executable lines (#634)
- `assert_true` and `assert_false` now report empty strings as assertion failures instead of trying to execute them

## [0.34.1](https://github.com/TypedDevs/bashunit/compare/0.34.0...0.34.1) - 2026-03-20

Expand Down
8 changes: 8 additions & 0 deletions src/assert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ function assert_true() {

# Check for expected literal values first
case "$actual" in
"")
bashunit::handle_bool_assertion_failure "true or 0" "$actual"
return
;;
"true" | "0")
bashunit::state::add_assertions_passed
return
Expand Down Expand Up @@ -71,6 +75,10 @@ function assert_false() {

# Check for expected literal values first
case "$actual" in
"")
bashunit::handle_bool_assertion_failure "false or 1" "$actual"
return
;;
"false" | "1")
bashunit::state::add_assertions_passed
return
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/assert_basic_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ function test_unsuccessful_assert_true() {
"$(assert_true false)"
}

function test_unsuccessful_assert_true_with_empty_value() {
assert_same "$(bashunit::console_results::print_failed_test "Unsuccessful assert true with empty value" \
"true or 0" \
"but got " "")" \
"$(assert_true "")"
}

function test_successful_assert_true_on_function() {
assert_empty "$(assert_true ls)"
}
Expand Down Expand Up @@ -62,6 +69,13 @@ function test_unsuccessful_assert_false() {
"$(assert_false true)"
}

function test_unsuccessful_assert_false_with_empty_value() {
assert_same "$(bashunit::console_results::print_failed_test "Unsuccessful assert false with empty value" \
"false or 1" \
"but got " "")" \
"$(assert_false "")"
}

function test_successful_assert_false_on_function() {
assert_empty "$(assert_false "eval return 1")"
}
Expand Down
Loading