Files
tactility/Tests/TactilityKernel/Source/PathsTest.cpp
Ken Van Hoeylandt 6fb2bb736c Drivers, device migrations and other improvements (#566)
- RGB display driver added
- display_driver API:
  - Added software-based display rotation for screens without hardware rotation support.
  - Improved display capability detection across supported display drivers.
- lvgl_display driver:
  - Improved framebuffer handling for smoother, more reliable display updates.
  - Display gap and rotation behavior now adapts more accurately to hardware capabilities.
- Migration Crowpanel 5" basic & advance to kernel drivers
- Improve KernelDisplay app: brightness controls are hidden for displays that only support on/off operation
- device.py now allows for (non-ambiguous) partial device IDs
- TactilityKernel: Implement more tests
2026-07-15 22:56:21 +02:00

32 lines
1.2 KiB
C++

#include "doctest.h"
#include <cstring>
#include <tactility/paths.h>
// The simulator target is never built with ESP_PLATFORM, so paths_get_user_data_path()
// always takes the fixed "data" path branch here, guarded by a buffer-size check.
TEST_CASE("paths_get_user_data_path succeeds when the buffer exactly fits") {
char buffer[16] = { 0 };
CHECK_EQ(paths_get_user_data_path(buffer, sizeof(buffer)), ERROR_NONE);
CHECK_EQ(std::strcmp(buffer, "data"), 0);
}
TEST_CASE("paths_get_user_data_path succeeds with a buffer sized to exactly fit the string and terminator") {
char buffer[5] = { 0 }; // strlen("data") + 1
CHECK_EQ(paths_get_user_data_path(buffer, sizeof(buffer)), ERROR_NONE);
CHECK_EQ(std::strcmp(buffer, "data"), 0);
}
TEST_CASE("paths_get_user_data_path reports a buffer overflow when the buffer is one byte too small") {
char buffer[4] = { 0 }; // strlen("data"), no room for the terminator
CHECK_EQ(paths_get_user_data_path(buffer, sizeof(buffer)), ERROR_BUFFER_OVERFLOW);
}
TEST_CASE("paths_get_user_data_path reports a buffer overflow for a zero-size buffer") {
char buffer[1] = { 'x' };
CHECK_EQ(paths_get_user_data_path(buffer, 0), ERROR_BUFFER_OVERFLOW);
CHECK_EQ(buffer[0], 'x'); // untouched
}