Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 557052be authored by Chris Manton's avatar Chris Manton
Browse files

mock: Update mock_osi_allocator|stub_osi with OsiObject

Bug: 324619910
Test: m .
Flag: EXEMPT, Test infrastructure

Change-Id: I93a12c066775a0faf028a6d0fc36d2cfcb197846
parent ccb71f81
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -23,10 +23,26 @@
// Mock include file to share data between tests and mock
#include "test/mock/mock_osi_allocator.h"

#include "osi/include/allocator.h"
#include "test/common/mock_functions.h"

// Mocked internal structures, if any

OsiObject::OsiObject(void* ptr) : ptr_(ptr) {}

OsiObject::OsiObject(const void* ptr) : ptr_(const_cast<void*>(ptr)) {}

OsiObject::~OsiObject() {
  if (ptr_ != nullptr) {
    osi_free(ptr_);
  }
}

void* OsiObject::Release() {
  void* ptr = ptr_;
  ptr_ = nullptr;
  return ptr;
}
namespace test {
namespace mock {
namespace osi_allocator {
+16 −0
Original line number Diff line number Diff line
@@ -47,6 +47,22 @@
#define UNUSED_ATTR
#endif

OsiObject::OsiObject(void* ptr) : ptr_(ptr) {}

OsiObject::OsiObject(const void* ptr) : ptr_(const_cast<void*>(ptr)) {}

OsiObject::~OsiObject() {
  if (ptr_ != nullptr) {
    osi_free(ptr_);
  }
}

void* OsiObject::Release() {
  void* ptr = ptr_;
  ptr_ = nullptr;
  return ptr;
}

struct StringComparison {
  bool operator()(char const* lhs, char const* rhs) const {
    return strcmp(lhs, rhs) < 0;