Files
reasampler/tests/test_lane_keys.cpp
T
daniel af34143107 feat(view): D2 Wave 2 — apply managed-lane ops + timer-diff auto-tag new content
Drives fixed-lane C_LANEPLAYS for managed lanes only (name-keyed, ordinal-renumber
safe) in the view shell; diffs live track/item GUIDs on the panel timer to auto-tag
new content to the active mode, first-poll-guarded. Pure guid_diff + lane_keys
modules unit-tested; folds in Wave-1 polish.
2026-07-23 17:32:22 -04:00

70 lines
2.7 KiB
C++

// Standalone tests for reasampler::lane_keys — no REAPER, no test framework. The pure
// managed/manual lane-name heuristic that resolves D2 design points #1 (auto-tag
// exemption) and #2 (durable lane identity vs ordinal renumber).
//
// Covers:
// 1. isManagedLaneName: only the "reasampler:" prefix is managed; everything else
// (empty, user comp names, near-miss prefixes) is manual.
// 2. managedLaneKey: managed name -> its durable key; manual/unnamed -> nullopt.
// 3. Round-trip: managedLaneKey(laneNameForMode(m)) == "reasampler:" + m, so the
// Wave-3 minting path and the read path cannot drift.
#include "../src/lane_keys.h"
#include <cstdio>
#include <string>
using namespace reasampler;
static int g_fail = 0;
#define CHECK(cond) do { if(!(cond)) { \
std::printf("FAIL line %d: %s\n", __LINE__, #cond); ++g_fail; } } while(0)
static void testIsManagedLaneName() {
// Tool-minted managed names.
CHECK(isManagedLaneName("reasampler:design"));
CHECK(isManagedLaneName("reasampler:arrange"));
CHECK(isManagedLaneName("reasampler:")); // prefix alone still ours (odd but managed)
// Manual / user lanes are never managed.
CHECK(!isManagedLaneName("")); // unnamed lane ⇒ manual
CHECK(!isManagedLaneName("Comp 1")); // user comp lane
CHECK(!isManagedLaneName("Lead vocal"));
CHECK(!isManagedLaneName("reasample")); // near-miss, no colon ⇒ not ours
CHECK(!isManagedLaneName("Reasampler:design")); // case-sensitive prefix
CHECK(!isManagedLaneName(" reasampler:x")); // leading space ⇒ not a prefix match
}
static void testManagedLaneKey() {
// Managed lane: the durable name IS the key.
auto k = managedLaneKey("reasampler:design");
CHECK(k.has_value() && *k == "reasampler:design");
// Manual / unnamed lanes have no managed key (⇒ treated as manual, never driven).
CHECK(!managedLaneKey("").has_value());
CHECK(!managedLaneKey("Comp 1").has_value());
CHECK(!managedLaneKey("guitar-double").has_value());
}
static void testRoundTrip() {
// Minting then reading must agree: managedLaneKey(laneNameForMode(m)) recovers the
// prefixed name for every mode id.
for (const std::string mode : {std::string("arrange"), std::string("design"),
std::string("mixdown")}) {
const std::string name = laneNameForMode(mode);
CHECK(name == "reasampler:" + mode);
CHECK(isManagedLaneName(name));
auto key = managedLaneKey(name);
CHECK(key.has_value() && *key == "reasampler:" + mode);
}
}
int main() {
testIsManagedLaneName();
testManagedLaneKey();
testRoundTrip();
if (g_fail == 0) std::printf("All tests passed.\n");
return g_fail ? 1 : 0;
}