Skip to content

Conversation

@ralphweng2023
Copy link

Description

Adds comprehensive automated unit tests for animation functions in SplashKit. The existing test_animation.cpp provides manual/interactive testing, but lacked automated unit tests that can be run as part of CI/CD pipelines.

This PR adds unit_test_animation.cpp which provides automated tests for:

Animation Script functions:

  • load_animation_script, free_animation_script, free_all_animation_scripts
  • has_animation_script, animation_script_named, animation_script_name
  • animation_count, has_animation_named, animation_index

Animation functions:

  • create_animation (multiple overloads with/without sound)
  • free_animation, assign_animation (multiple overloads)
  • animation_name, animation_current_cell, animation_ended
  • animation_entered_frame, animation_frame_time, animation_current_vector
  • update_animation, restart_animation

Edge case handling:

  • Null/invalid pointer handling for all getter functions
  • Invalid script file loading
  • Animation lifecycle testing (create → update → end → restart)

The tests use the existing kermit.txt animation script resource and follow the same patterns as other unit tests in the project.

Type of change

  • New tests

How Has This Been Tested?

Built the test project using CMake as per build instructions. All tests pass successfully.

Automated Testing:

cd projects/cmake
cmake --preset macOS
cmake --build build/

cd ../../bin
./skunit_tests "[animation],[animation_script]" --success
# Result: All tests passed (86 assertions in 9 test cases)

./skunit_tests --order rand
# Result: All tests passed (1349 assertions in 88 test cases)

Testing Checklist

  • Code compiles without errors
  • All 9 new animation test cases pass (86 assertions)
  • All existing tests still pass (88 total test cases, 1349 assertions)
  • Tests run independently in random order

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • My changes generate no new warnings
  • New tests have been added to prove the functionality works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants