|
|
|
@ -132,7 +132,8 @@ void ResourceManagerTest::stateDisallowed() { |
|
|
|
std::ostringstream out; |
|
|
|
std::ostringstream out; |
|
|
|
Error redirectError{&out}; |
|
|
|
Error redirectError{&out}; |
|
|
|
|
|
|
|
|
|
|
|
rm.set("data", Data(), ResourceDataState::Loading, ResourcePolicy::Resident); |
|
|
|
Data d; /* Done this way to prevent memory leak on assertion (yes, the code is bad) */ |
|
|
|
|
|
|
|
rm.set("data", &d, ResourceDataState::Loading, ResourcePolicy::Resident); |
|
|
|
CORRADE_COMPARE(out.str(), "ResourceManager::set(): data should be null if and only if state is NotFound or Loading\n"); |
|
|
|
CORRADE_COMPARE(out.str(), "ResourceManager::set(): data should be null if and only if state is NotFound or Loading\n"); |
|
|
|
|
|
|
|
|
|
|
|
out.str({}); |
|
|
|
out.str({}); |
|
|
|
@ -161,7 +162,8 @@ void ResourceManagerTest::basic() { |
|
|
|
/* Cannot change already final resource */ |
|
|
|
/* Cannot change already final resource */ |
|
|
|
std::ostringstream out; |
|
|
|
std::ostringstream out; |
|
|
|
Error redirectError{&out}; |
|
|
|
Error redirectError{&out}; |
|
|
|
rm.set(answerKey, 43, ResourceDataState::Mutable, ResourcePolicy::Resident); |
|
|
|
int a = 43; /* Done this way to prevent a memory leak on assert (yes, the code is bad) */ |
|
|
|
|
|
|
|
rm.set(answerKey, &a, ResourceDataState::Mutable, ResourcePolicy::Resident); |
|
|
|
CORRADE_COMPARE(*theAnswer, 42); |
|
|
|
CORRADE_COMPARE(*theAnswer, 42); |
|
|
|
CORRADE_COMPARE(out.str(), "ResourceManager::set(): cannot change already final resource " + answerKey.hexString() + '\n'); |
|
|
|
CORRADE_COMPARE(out.str(), "ResourceManager::set(): cannot change already final resource " + answerKey.hexString() + '\n'); |
|
|
|
|
|
|
|
|
|
|
|
@ -263,9 +265,10 @@ void ResourceManagerTest::clearWhileReferenced() { |
|
|
|
Error redirectError{&out}; |
|
|
|
Error redirectError{&out}; |
|
|
|
|
|
|
|
|
|
|
|
ResourceManager rm; |
|
|
|
ResourceManager rm; |
|
|
|
rm.set("blah", Int()); |
|
|
|
int a{}; /* Done this way to prevent leak on assertion (yes, the code is bad) */ |
|
|
|
/** @todo this will leak, is there any better solution without hitting
|
|
|
|
rm.set("blah", &a); |
|
|
|
assertion in decrementReferenceCount()? */ |
|
|
|
/** @todo this will leak, is there any better solution without hitting assertion in decrementReferenceCount()? */ |
|
|
|
|
|
|
|
/** @todo remove the suppression from package/ci/leaksanitizer.conf then */ |
|
|
|
new Resource<Int>(rm.get<Int>("blah")); |
|
|
|
new Resource<Int>(rm.get<Int>("blah")); |
|
|
|
|
|
|
|
|
|
|
|
rm.clear(); |
|
|
|
rm.clear(); |
|
|
|
|