mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Add an internal ASSERT macro
This macro has some advantages over the standard library one: - It prints the place where the macro was triggered - It "references" the condition even in Release to avoid warnings - In release, if possible, it gives compiler hints It is basically is stripped down version of the ASSERT macros I wrote for the Daemon engine in src/common/Assert.h This commit also removes the stray "backend" namespaces for common/ code.
This commit is contained in:
committed by
Corentin Wallez
parent
bd0594bab8
commit
fd589f3919
@@ -14,13 +14,11 @@
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "utils/BackendBinding.h"
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
|
||||
#include <cassert>
|
||||
#define ASSERT assert
|
||||
|
||||
namespace {
|
||||
|
||||
utils::BackendType ParamToBackendType(BackendType type) {
|
||||
@@ -34,7 +32,7 @@ namespace {
|
||||
case VulkanBackend:
|
||||
return utils::BackendType::Vulkan;
|
||||
default:
|
||||
ASSERT(false);
|
||||
NXT_ASSERT(false);
|
||||
return utils::BackendType::Null;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +48,7 @@ namespace {
|
||||
case VulkanBackend:
|
||||
return "Vulkan";
|
||||
default:
|
||||
ASSERT(false);
|
||||
NXT_ASSERT(false);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -107,10 +105,10 @@ NXTTest::~NXTTest() {
|
||||
|
||||
void NXTTest::SetUp() {
|
||||
binding = utils::CreateBinding(ParamToBackendType(GetParam()));
|
||||
ASSERT(binding != nullptr);
|
||||
NXT_ASSERT(binding != nullptr);
|
||||
|
||||
GLFWwindow* testWindow = GetWindowForBackend(binding, GetParam());
|
||||
ASSERT(testWindow != nullptr);
|
||||
NXT_ASSERT(testWindow != nullptr);
|
||||
|
||||
binding->SetWindow(testWindow);
|
||||
|
||||
@@ -231,7 +229,7 @@ void NXTTest::MapSlotsSynchronously() {
|
||||
|
||||
// static
|
||||
void NXTTest::SlotMapReadCallback(nxtBufferMapReadStatus status, const void* data, nxtCallbackUserdata userdata_) {
|
||||
ASSERT(status == NXT_BUFFER_MAP_READ_STATUS_SUCCESS);
|
||||
NXT_ASSERT(status == NXT_BUFFER_MAP_READ_STATUS_SUCCESS);
|
||||
|
||||
auto userdata = reinterpret_cast<MapReadUserdata*>(static_cast<uintptr_t>(userdata_));
|
||||
userdata->test->readbackSlots[userdata->slot].mappedData = data;
|
||||
@@ -242,7 +240,7 @@ void NXTTest::SlotMapReadCallback(nxtBufferMapReadStatus status, const void* dat
|
||||
|
||||
void NXTTest::ResolveExpectations() {
|
||||
for(const auto& expectation : deferredExpectations) {
|
||||
ASSERT(readbackSlots[expectation.readbackSlot].mappedData != nullptr);
|
||||
NXT_ASSERT(readbackSlots[expectation.readbackSlot].mappedData != nullptr);
|
||||
|
||||
// Get a pointer to the mapped copy of the data for the expectation.
|
||||
const char* data = reinterpret_cast<const char*>(readbackSlots[expectation.readbackSlot].mappedData);
|
||||
@@ -314,7 +312,7 @@ namespace detail {
|
||||
|
||||
template<typename T>
|
||||
testing::AssertionResult ExpectEq<T>::Check(const void* data, size_t size) {
|
||||
ASSERT(size == sizeof(T) * expected.size());
|
||||
NXT_ASSERT(size == sizeof(T) * expected.size());
|
||||
|
||||
const T* actual = reinterpret_cast<const T*>(data);
|
||||
for (size_t i = 0; i < expected.size(); ++i) {
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
// This is ANGLE's BitSetIterator_unittests.cpp file.
|
||||
|
||||
using namespace backend;
|
||||
|
||||
class BitSetIteratorTest : public testing::Test {
|
||||
protected:
|
||||
std::bitset<40> mStateBits;
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
#include "common/Math.h"
|
||||
|
||||
using namespace backend;
|
||||
|
||||
// Tests for ScanForward
|
||||
TEST(Math, ScanForward) {
|
||||
// Test extrema
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
#include "common/SerialQueue.h"
|
||||
|
||||
using SerialQueue = backend::SerialQueue<int>;
|
||||
using TestSerialQueue = SerialQueue<int>;
|
||||
|
||||
// A number of basic tests for SerialQueue that are difficult to split from one another
|
||||
TEST(SerialQueue, BasicTest) {
|
||||
SerialQueue queue;
|
||||
TestSerialQueue queue;
|
||||
|
||||
// Queue starts empty
|
||||
ASSERT_TRUE(queue.Empty());
|
||||
@@ -57,7 +57,7 @@ TEST(SerialQueue, BasicTest) {
|
||||
|
||||
// Test enqueuing vectors works
|
||||
TEST(SerialQueue, EnqueueVectors) {
|
||||
SerialQueue queue;
|
||||
TestSerialQueue queue;
|
||||
|
||||
std::vector<int> vector1 = {1, 2, 3, 4};
|
||||
std::vector<int> vector2 = {5, 6, 7, 8};
|
||||
@@ -78,7 +78,7 @@ TEST(SerialQueue, EnqueueVectors) {
|
||||
|
||||
// Test IterateUpTo
|
||||
TEST(SerialQueue, IterateUpTo) {
|
||||
SerialQueue queue;
|
||||
TestSerialQueue queue;
|
||||
|
||||
std::vector<int> vector1 = {1, 2, 3, 4};
|
||||
std::vector<int> vector2 = {5, 6, 7, 8};
|
||||
@@ -99,7 +99,7 @@ TEST(SerialQueue, IterateUpTo) {
|
||||
|
||||
// Test ClearUpTo
|
||||
TEST(SerialQueue, ClearUpTo) {
|
||||
SerialQueue queue;
|
||||
TestSerialQueue queue;
|
||||
|
||||
std::vector<int> vector1 = {1, 2, 3, 4};
|
||||
std::vector<int> vector2 = {5, 6, 7, 8};
|
||||
@@ -122,7 +122,7 @@ TEST(SerialQueue, ClearUpTo) {
|
||||
|
||||
// Test FirstSerial
|
||||
TEST(SerialQueue, FirstSerial) {
|
||||
SerialQueue queue;
|
||||
TestSerialQueue queue;
|
||||
|
||||
std::vector<int> vector1 = {1, 2, 3, 4};
|
||||
std::vector<int> vector2 = {5, 6, 7, 8};
|
||||
|
||||
Reference in New Issue
Block a user