1+ /* *
2+ * Bundle unit tests
3+ */
4+
5+ #include " catch.hpp"
6+
7+ #include " bundles.h"
8+ #include " resources.h"
9+ #include " audio.h"
10+ #include " images.h"
11+ #include " timers.h"
12+ #include " text.h"
13+
14+ using namespace splashkit_lib ;
15+
16+ // Log pointers of freed resources
17+ void free_notification (void *resource)
18+ {
19+ UNSCOPED_INFO (" Freeing: " << resource);
20+ }
21+
22+ TEST_CASE (" Load and free resource bundle" , " [load_resource_bundle][free_resource_bundle]" )
23+ {
24+ register_free_notifier (&free_notification);
25+
26+ /* *
27+ * Load test resource bundle containing:
28+ * ANIM,WalkingScript,kermit.txt
29+ * BITMAP,FrogBmp,frog.png, 73, 105, 4, 4, 16
30+ * FONT,hara,hara.ttf
31+ * SOUND,error,error.wav
32+ * MUSIC,background,energize_my_mind.mod
33+ * TIMER,my timer
34+ * BUNDLE,blah,blah.txt
35+ */
36+ load_resource_bundle (" test" , " test.txt" );
37+
38+ // Confirm bundle and its resources are loaded
39+ REQUIRE (has_resource_bundle (" test" ));
40+ REQUIRE (has_animation_script (" WalkingScript" ));
41+ REQUIRE (has_bitmap (" FrogBmp" ));
42+ REQUIRE (has_font (" hara" ));
43+ REQUIRE (has_sound_effect (" error" ));
44+ REQUIRE (has_music (" background" ));
45+ REQUIRE (has_timer (" my timer" ));
46+ REQUIRE (has_resource_bundle (" blah" ));
47+ REQUIRE (has_bitmap (" ufo" ));
48+ REQUIRE (has_resource_bundle (" test" ));
49+
50+ // Free bundle and confirm resources are freed
51+ free_resource_bundle (" test" );
52+
53+ REQUIRE_FALSE (has_resource_bundle (" test" ));
54+ REQUIRE_FALSE (has_animation_script (" WalkingScript" ));
55+ REQUIRE_FALSE (has_bitmap (" FrogBmp" ));
56+ REQUIRE_FALSE (has_font (" hara" ));
57+ REQUIRE_FALSE (has_sound_effect (" error" ));
58+ REQUIRE_FALSE (has_music (" background" ));
59+ REQUIRE_FALSE (has_timer (" my timer" ));
60+ REQUIRE_FALSE (has_resource_bundle (" blah" ));
61+ REQUIRE_FALSE (has_bitmap (" ufo" ));
62+ }
0 commit comments