// Step 1946: PipelineParityValidator // // t1: setReference and referenceCount // t2: validate passes when all outputs match references // t3: validate fails when output mismatches reference // t4: validate fails when success=false regardless of output // t5: stagePass correct; no reference set always passes #include "PipelineParityValidator.h" #include namespace ws = whetstone; static int p=0,f=0; #define T(n) { std::cout<<" "<<#n<<"... "; } #define P() { std::cout<<"PASS\n"; ++p; } #define F(m) { std::cout<<"FAIL: "< outputs = { {"ingest","Python","records\n",true}, {"norm", "Rust", "normed\n", true} }; auto r = v.validate(outputs); C(r.passed, "passed"); C(r.failedStages.empty(),"no failures"); P(); } void t3(){ T(validate_fails_on_mismatch); ws::PipelineParityValidator v; v.setReference("norm","normed\n"); std::vector outputs = { {"norm","Rust","WRONG\n",true} }; auto r = v.validate(outputs); C(!r.passed, "not passed"); C(r.failedStages.size()==1,"one failure"); C(r.failedStages[0]=="norm","norm failed"); P(); } void t4(){ T(validate_fails_when_success_false); ws::PipelineParityValidator v; v.setReference("fanout","batches\n"); std::vector outputs = { {"fanout","Go","batches\n",false} // success=false despite matching output }; auto r = v.validate(outputs); C(!r.passed, "not passed (success=false)"); C(r.failedStages[0]=="fanout","fanout failed"); // Stage with no reference but success=false also fails std::vector outputs2 = {{"x","Go","anything",false}}; auto r2 = v.validate(outputs2); C(!r2.passed, "no-ref stage fails when success=false"); P(); } void t5(){ T(stagePass_with_and_without_reference); ws::PipelineParityValidator v; v.setReference("norm","normed\n"); C( v.stagePass("norm","normed\n"), "correct output passes"); C(!v.stagePass("norm","wrong\n"), "wrong output fails"); C( v.stagePass("unknown","anything"),"no reference always passes"); P(); } int main(){ std::cout << "Step 1946: PipelineParityValidator\n"; t1(); t2(); t3(); t4(); t5(); std::cout << "\n" << p << "/" << (p+f) << " passed\n"; return f > 0 ? 1 : 0; }