Skip to content

Commit

Permalink
maxmimize test coverage of living/vitals
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelprograms committed Feb 7, 2025
1 parent c08c2e3 commit 54181a3
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion lib/std/living/vitals.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ void test_update_vitals () {
assert_equal(testOb->query_mp(), 10),
assert_equal(testOb->query_mp() == testOb->query_max_mp(), 1),
}) :));

expect("null vitals are initialized", (: ({
assert_equal(testOb->query_hp(), 20),
assert_equal(testOb->query_max_hp(), 20),
assert_equal(testOb->query_sp(), 10),
assert_equal(testOb->query_max_sp(), 10),
assert_equal(testOb->query_mp(), 10),
assert_equal(testOb->query_max_mp(), 10),
store_variable("__Vitals", UNDEFINED, testOb),
testOb->update_vitals(0), // don't heal
assert_equal(testOb->query_hp(), 0),
assert_equal(testOb->query_max_hp(), 20),
assert_equal(testOb->query_sp(), 0),
assert_equal(testOb->query_max_sp(), 10),
assert_equal(testOb->query_mp(), 0),
assert_equal(testOb->query_max_mp(), 10),
}) :));
}

void test_hp () {
Expand All @@ -42,6 +59,10 @@ void test_hp () {

testOb->add_hp(1), // already max
assert_equal(testOb->query_hp(), 20),
assert_equal(testOb->query_max_hp(), 20),

testOb->set_hp(100), // can't go above max
assert_equal(testOb->query_hp(), 20),

testOb->add_hp(-10),
assert_equal(testOb->query_hp(), 10),
Expand All @@ -66,14 +87,18 @@ void test_sp () {

testOb->add_sp(1), // already max
assert_equal(testOb->query_sp(), 10),
assert_equal(testOb->query_max_sp(), 10),

testOb->set_sp(100), // can't go above max
assert_equal(testOb->query_sp(), 10),

testOb->add_sp(-5),
assert_equal(testOb->query_sp(), 5),
testOb->add_sp(2),
assert_equal(testOb->query_sp(), 7),
testOb->add_sp(0),
assert_equal(testOb->query_sp(), 7),
testOb->add_sp(5), // attespt to go over max
testOb->add_sp(5), // attempt to go over max
assert_equal(testOb->query_sp(), 10),

testOb->set_sp(5),
Expand All @@ -90,6 +115,10 @@ void test_mp () {

testOb->add_mp(1), // already max
assert_equal(testOb->query_mp(), 10),
assert_equal(testOb->query_max_mp(), 10),

testOb->set_mp(100), // can't go above max
assert_equal(testOb->query_mp(), 10),

testOb->add_mp(-5),
assert_equal(testOb->query_mp(), 5),
Expand Down

0 comments on commit 54181a3

Please sign in to comment.