Files
whetstone_DSL/editor/tests/step876_test.cpp

65 lines
3.4 KiB
C++
Raw Normal View History

// Step 876: whetstone_estimate_porting_cost MCP tool (8 tests)
#include "MCPServer.h"
#include <iostream>
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: " << m << "\n"; ++f; }
#define C(c,m) if(!(c)){F(m);return;}
void t1(){T(tool_registered);
MCPServer srv;
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/list"},{"params",{}}});
bool found=false;
for(auto& t:r["result"]["tools"]) if(t["name"]=="whetstone_estimate_porting_cost") found=true;
C(found,"tool found");P();}
void t2(){T(no_pair_id_fails);
MCPServer srv;
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",nlohmann::json::object()}}}});
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
C(!res["success"].get<bool>(),"fail");P();}
void t3(){T(valid_pair_succeeds);
MCPServer srv;
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"}}}}}});
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
C(res["success"].get<bool>(),"success");P();}
void t4(){T(tier_field_present);
MCPServer srv;
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"}}}}}});
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
C(res.contains("tier"),"tier");P();}
void t5(){T(total_cost_present);
MCPServer srv;
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"}}}}}});
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
C(res.contains("total_cost"),"total");P();}
void t6(){T(high_loc_high_compute);
MCPServer srv;
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"},{"lines_of_code",5000},{"ambiguity_score",0.9}}}}}});
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
C(res["tier"]=="high","high");P();}
void t7(){T(low_loc_low_tier);
MCPServer srv;
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"},{"lines_of_code",10},{"ambiguity_score",0.0}}}}}});
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
C(res["tier"]=="low","low");P();}
void t8(){T(pair_id_in_response);
MCPServer srv;
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","rust->go"}}}}}});
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
C(res["pair_id"]=="rust->go","pair_id");P();}
int main(){
std::cout<<"Step 876: whetstone_estimate_porting_cost\n";
t1();t2();t3();t4();t5();t6();t7();t8();
std::cout<<"\nResults: "<<p<<"/"<<(p+f)<<" passed\n";
return f?1:0;
}