summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-06-04 18:01:10 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-06-04 18:01:10 +0100
commit2c87aa33dfde23920d1dccd04c472c8884118b90 (patch)
treea90075a27f8490d440957526bf05c9dd6121bc0a /test
parentAssign an id to the root project (diff)
downloadilt-2c87aa33dfde23920d1dccd04c472c8884118b90.tar.bz2
ilt-2c87aa33dfde23920d1dccd04c472c8884118b90.tar.xz
ilt-2c87aa33dfde23920d1dccd04c472c8884118b90.zip
Replace messy uasprintf with std::format
Diffstat (limited to 'test')
-rw-r--r--test/testHelpers.cpp16
-rw-r--r--test/testHelpers.h3
-rw-r--r--test/testMainWindow.cpp10
3 files changed, 5 insertions, 24 deletions
diff --git a/test/testHelpers.cpp b/test/testHelpers.cpp
deleted file mode 100644
index c69e5f3..0000000
--- a/test/testHelpers.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "testHelpers.h"
-#include <cstdarg>
-
-std::unique_ptr<char, decltype(&free)>
-uasprintf(const char * fmt, ...)
-{
- char * buf {};
- va_list args;
- va_start(args, fmt);
- if (vasprintf(&buf, fmt, args) < 0) {
- va_end(args);
- return {nullptr, &free};
- }
- va_end(args);
- return std::unique_ptr<char, decltype(&free)> {buf, &free};
-}
diff --git a/test/testHelpers.h b/test/testHelpers.h
index 58e4372..c9fd6dc 100644
--- a/test/testHelpers.h
+++ b/test/testHelpers.h
@@ -6,9 +6,6 @@
#include <fstream>
#include <iomanip> // IWYU pragma: keep std::setprecision
#include <jsonParse-persistence.h>
-#include <memory>
-
-std::unique_ptr<char, decltype(&free)> uasprintf(const char * fmt, ...) __attribute__((format(printf, 1, 2)));
template<typename T>
decltype(auto)
diff --git a/test/testMainWindow.cpp b/test/testMainWindow.cpp
index 57e3473..d0b674c 100644
--- a/test/testMainWindow.cpp
+++ b/test/testMainWindow.cpp
@@ -1,6 +1,6 @@
#include "testMainWindow.h"
-#include "testHelpers.h"
#include <boost/test/test_tools.hpp>
+#include <format>
TestMainWindow::TestMainWindow() : Window {1, 1, __FILE__, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN}
{
@@ -8,18 +8,18 @@ TestMainWindow::TestMainWindow() : Window {1, 1, __FILE__, SDL_WINDOW_OPENGL | S
glDebugMessageCallback(
[](GLenum /*source*/, GLenum type, GLuint /*id*/, GLenum severity, GLsizei /*length*/,
const GLchar * message, const void *) {
- const auto msg = uasprintf("GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s",
+ const auto msg = std::format("GL CALLBACK: {} type = 0x{:x}, severity = 0x{:x}, message = {}",
(type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), type, severity, message);
switch (type) {
case GL_DEBUG_TYPE_ERROR:
case GL_DEBUG_TYPE_PORTABILITY:
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
- BOOST_TEST_ERROR(msg.get());
+ BOOST_TEST_ERROR(msg);
case GL_DEBUG_TYPE_PERFORMANCE:
- BOOST_TEST_WARN(msg.get());
+ BOOST_TEST_WARN(msg.c_str());
default:
- BOOST_TEST_MESSAGE(msg.get());
+ BOOST_TEST_MESSAGE(msg);
}
},
nullptr);