compute-runtime/unit_tests/utilities/destructor_counted.h

28 lines
633 B
C++

/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "test.h"
namespace OCLRT {
template <typename BaseType, uint32_t ordinal>
struct DestructorCounted : public BaseType {
template <typename... Args>
DestructorCounted(uint32_t &destructorId, Args &&... args) : BaseType(std::forward<Args>(args)...),
destructorId(destructorId) {}
~DestructorCounted() override {
EXPECT_EQ(ordinal, destructorId);
destructorId++;
}
private:
uint32_t &destructorId;
};
} // namespace OCLRT