Skip to content
Open
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
2 changes: 1 addition & 1 deletion coresdk/src/coresdk/bundles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace splashkit_lib
break;
case IMAGE_RESOURCE:
rb_load_bitmap(line_name, line_path);
if ( ! has_resource_bundle(line_name) ) return;
if ( ! has_bitmap(line_name) ) return;
break;
case FONT_RESOURCE:
load_font(line_name, line_path);
Expand Down
62 changes: 62 additions & 0 deletions coresdk/src/test/unit_tests/unit_test_bundles.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Bundle unit tests
*/

#include "catch.hpp"

#include "bundles.h"
#include "resources.h"
#include "audio.h"
#include "images.h"
#include "timers.h"
#include "text.h"

using namespace splashkit_lib;

// Log pointers of freed resources
void free_notification(void *resource)
{
UNSCOPED_INFO("Freeing: " << resource);
}

TEST_CASE("Load and free resource bundle", "[load_resource_bundle][free_resource_bundle]")
{
register_free_notifier(&free_notification);

/**
* Load test resource bundle containing:
* ANIM,WalkingScript,kermit.txt
* BITMAP,FrogBmp,frog.png, 73, 105, 4, 4, 16
* FONT,hara,hara.ttf
* SOUND,error,error.wav
* MUSIC,background,energize_my_mind.mod
* TIMER,my timer
* BUNDLE,blah,blah.txt
*/
load_resource_bundle("test", "test.txt");

// Confirm bundle and its resources are loaded
REQUIRE(has_resource_bundle("test"));
REQUIRE(has_animation_script("WalkingScript"));
REQUIRE(has_bitmap("FrogBmp"));
REQUIRE(has_font("hara"));
REQUIRE(has_sound_effect("error"));
REQUIRE(has_music("background"));
REQUIRE(has_timer("my timer"));
REQUIRE(has_resource_bundle("blah"));
REQUIRE(has_bitmap("ufo"));
REQUIRE(has_resource_bundle("test"));

// Free bundle and confirm resources are freed
free_resource_bundle("test");

REQUIRE_FALSE(has_resource_bundle("test"));
REQUIRE_FALSE(has_animation_script("WalkingScript"));
REQUIRE_FALSE(has_bitmap("FrogBmp"));
REQUIRE_FALSE(has_font("hara"));
REQUIRE_FALSE(has_sound_effect("error"));
REQUIRE_FALSE(has_music("background"));
REQUIRE_FALSE(has_timer("my timer"));
REQUIRE_FALSE(has_resource_bundle("blah"));
REQUIRE_FALSE(has_bitmap("ufo"));
}
Loading