first commit

This commit is contained in:
stuce-bot 2025-06-30 20:47:33 +02:00
commit 5893b00dd2
1669 changed files with 1982740 additions and 0 deletions

View file

@ -0,0 +1,45 @@
// g++ --std=c++11 test.cpp
#include "test.h"
#include "test.h"
#include "FastLED.h"
#include "cled_controller.h"
#include "platforms/wasm/strip_id_map.h"
#include "fl/namespace.h"
FASTLED_USING_NAMESPACE
struct FakeSpi {
int value = 0;
};
class FakeCLedController : public CLEDController {
public:
FakeSpi fake_spi;
virtual void showColor(const CRGB &data, int nLeds,
uint8_t brightness) override {}
virtual void show(const struct CRGB *data, int nLeds,
uint8_t brightness) override {}
virtual void init() override {}
};
TEST_CASE("StripIdMap Simple Test") {
StripIdMap::test_clear();
FakeCLedController fake_controller;
int id = StripIdMap::addOrGetId(&fake_controller);
CHECK(id == 0);
CLEDController *owner = StripIdMap::getOwner(id);
CLEDController *match = &fake_controller;
printf("Owner: %p, Match: %p\n", owner, match);
CHECK_EQ(owner, match);
CHECK(StripIdMap::getId(&fake_controller) == 0);
id = StripIdMap::getOrFindByAddress(reinterpret_cast<uintptr_t>(&fake_controller));
CHECK(id == 0);
id = StripIdMap::getOrFindByAddress(reinterpret_cast<uintptr_t>(&fake_controller.fake_spi));
CHECK(id == 0);
}