Q-W1 pt1: extract core/json (json::Reader/Writer), collapse wire Cursor family into core/wire, shared readFileBytes — five JSON decoders and three cursor copies deleted, byte-identical formats, 59/59 green
This commit is contained in:
@@ -135,6 +135,20 @@ static void testRoundTripAuto() {
|
||||
CHECK(back && settingsEqual(*back, s));
|
||||
}
|
||||
|
||||
static void testSerializeByteIdentity() {
|
||||
// Q-W1 structural-dedupe guard: the core/json-backed writer must emit the
|
||||
// EXACT bytes the former snprintf writer produced ({"mode":%d,"manualMs":%.17g})
|
||||
// and re-serializing a round-tripped setting must be byte-identical — the blob
|
||||
// lives in the .rpp, so a byte shift would dirty every saved project.
|
||||
TailSetting s; // None + 2000.0 default
|
||||
CHECK(serializeTailSetting(s) == "{\"mode\":0,\"manualMs\":2000}");
|
||||
TailSetting man; man.mode = TailMode::Manual; man.manualMs = 3141.592653589793;
|
||||
const std::string json = serializeTailSetting(man);
|
||||
auto back = deserializeTailSetting(json);
|
||||
CHECK(back.has_value());
|
||||
CHECK(back && serializeTailSetting(*back) == json); // stable second round-trip
|
||||
}
|
||||
|
||||
static void testDeserializeEmptyIsDefault() {
|
||||
// An absent/empty stored value (older project) -> nullopt, so the caller falls
|
||||
// back to the default. This is the graceful-old-project path the brief requires.
|
||||
@@ -164,6 +178,7 @@ int main() {
|
||||
testRoundTripNoneDefault();
|
||||
testRoundTripManualArbitraryMs();
|
||||
testRoundTripAuto();
|
||||
testSerializeByteIdentity();
|
||||
testDeserializeEmptyIsDefault();
|
||||
testDeserializeMalformedIsDefault();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user