结构优化
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <cstdint>
|
||||
#include <gtest/gtest.h>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include "../Renderive/base/Memory.h"
|
||||
@@ -7,19 +8,22 @@ struct Payload {
|
||||
std::uint64_t value{};
|
||||
};
|
||||
}
|
||||
int main() {
|
||||
TEST(Memory_Default, AllocatesAndTracksDefaultResource) {
|
||||
std::pmr::vector<std::uint64_t> values(renderive::memory_resource());
|
||||
values.resize(4096, 7);
|
||||
auto owner = renderive::make_shared<Payload>();
|
||||
owner->value = values.front();
|
||||
if (owner->value != 7)
|
||||
return 1;
|
||||
EXPECT_EQ(owner->value, 7);
|
||||
std::thread release_thread([owner = std::move(owner)]() mutable {
|
||||
owner.reset();
|
||||
});
|
||||
release_thread.join();
|
||||
renderive::Memory_Stats stats = renderive::memory_stats();
|
||||
if (!stats.upstream_allocation_count || !stats.upstream_current_bytes || !stats.upstream_peak_bytes)
|
||||
return 2;
|
||||
return 0;
|
||||
EXPECT_GT(stats.upstream_allocation_count, 0);
|
||||
EXPECT_GT(stats.upstream_current_bytes, 0);
|
||||
EXPECT_GT(stats.upstream_peak_bytes, 0);
|
||||
}
|
||||
int main(int argc, char** argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user