29 lines
1.0 KiB
C++
29 lines
1.0 KiB
C++
#include <QApplication>
|
|
#include <stdexcept>
|
|
#include <gtest/gtest.h>
|
|
#include "../Renderive/plot/Latency_Eager_Plot.h"
|
|
#include "../Renderive/base/Memory.h"
|
|
namespace {
|
|
void* callback_allocate(void*, std::size_t size, std::size_t alignment) {
|
|
return std::pmr::new_delete_resource()->allocate(size, alignment);
|
|
}
|
|
void callback_deallocate(void*, void* address, std::size_t size, std::size_t alignment) {
|
|
std::pmr::new_delete_resource()->deallocate(address, size, alignment);
|
|
}
|
|
}
|
|
TEST(Memory_Plot_Late_Config, RejectsCallbacksAfterPlotCreatesMemory) {
|
|
renderive::start_render_scheduler();
|
|
renderive::Latency_Eager_Plot plot;
|
|
plot.init();
|
|
renderive::Memory_Callbacks callbacks;
|
|
callbacks.allocate = callback_allocate;
|
|
callbacks.deallocate = callback_deallocate;
|
|
EXPECT_THROW(renderive::set_memory_callbacks(callbacks), std::logic_error);
|
|
}
|
|
int main(int argc, char** argv) {
|
|
qputenv("QT_QPA_PLATFORM", "offscreen");
|
|
QApplication app(argc, argv);
|
|
testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|