mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
* **New Features** * Added public accessors for querying module/device start and ready state. * **Refactor** * Internal state moved to opaque internal objects; module/device/driver initializers now explicitly initialize internal pointers. * Lifecycle handling updated to construct/destruct internal state and use accessors. * **Tests** * Tests updated to use public accessors and explicit construct/destruct lifecycle calls. * **Chores** * Test build/include paths and small metadata updated.
42 lines
799 B
C++
42 lines
799 B
C++
#pragma once
|
|
|
|
#include "doctest.h"
|
|
#include <unistd.h>
|
|
|
|
#include <Tactility/file/File.h>
|
|
|
|
/**
|
|
* A class for creating test files that can automatically clean themselves up.
|
|
*/
|
|
class TestFile {
|
|
const char* path;
|
|
bool autoClean;
|
|
|
|
public:
|
|
|
|
TestFile(const char* path, bool autoClean = true) : path(path), autoClean(autoClean) {
|
|
if (autoClean && exists()) {
|
|
remove();
|
|
}
|
|
}
|
|
|
|
~TestFile() {
|
|
if (autoClean && exists()) {
|
|
remove();
|
|
}
|
|
}
|
|
|
|
const char* getPath() const { return path; }
|
|
|
|
void writeData(const char* data) const {
|
|
CHECK_EQ(tt::file::writeString(path, data), true);
|
|
}
|
|
|
|
bool exists() const {
|
|
return access(path, F_OK) == 0;
|
|
}
|
|
|
|
void remove() const {
|
|
::remove(path);
|
|
}
|
|
}; |