Files
compute-runtime/shared/test/common/helpers/gtest_helpers.h
Warchulski, Jaroslaw a6c1d9578e Move files between shared/test/common/helpers and shared/test/unit_test/helpersi
unit_test/helpers/cmd_buffer_validator.h -> common/helpers
unit_test/helpers/gtest_helpers.h -> common/helpers
common/helpers/blit_commands_helper_tests.inl -> unit_test/helpers
common/helpers/simd_helper_tests.inl -> unit_test/helpers
common/helpers/simd_helper_tests_pvc_and_later.inl -> unit_test/helpers
common/helpers/state_base_address_tests.h -> unit_test/helpers

Related-To: NEO-6524
Signed-off-by: Warchulski, Jaroslaw <jaroslaw.warchulski@intel.com>
2022-08-10 15:23:12 +02:00

78 lines
1.8 KiB
C++

/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <cstdint>
#include <regex>
#include <stddef.h>
#include <string>
#define EXPECT_EQ_VAL(a, b) \
{ \
auto evalA = (a); \
auto evalB = (b); \
EXPECT_EQ(evalA, evalB); \
}
#define EXPECT_NE_VAL(a, b) \
{ \
auto evalA = (a); \
auto evalB = (b); \
EXPECT_NE(evalA, evalB); \
}
#define EXPECT_GT_VAL(a, b) \
{ \
auto evalA = (a); \
auto evalB = (b); \
EXPECT_GT(evalA, evalB); \
}
#define EXPECT_EQ_CONST(a, b) \
{ \
decltype(b) expected = (a); \
EXPECT_EQ_VAL(expected, b); \
}
inline bool memoryZeroed(const void *mem, const size_t size) {
size_t sizeLeft = (size_t)size;
bool memoryZeroed = true;
while (--sizeLeft) {
uint8_t *pMem = (uint8_t *)mem;
if (pMem[sizeLeft] != 0) {
memoryZeroed = false;
break;
}
}
return memoryZeroed;
}
inline bool hasSubstr(const std::string &str, const std::string &subStr) {
return std::string::npos != str.find(subStr);
}
inline bool startsWith(const std::string &str, const std::string &subStr) {
return 0 == str.find(subStr, 0);
}
inline bool endsWith(const std::string &str, const std::string &subStr) {
if (subStr.size() > str.size()) {
return false;
}
return 0 == str.compare(str.size() - subStr.size(), subStr.size(), subStr);
}
inline bool isEmpty(const std::string &str) {
return str.empty();
}
inline bool containsRegex(const std::string &str, const std::string &regex) {
return std::regex_search(str, std::regex(regex));
}