string SchemaEngine::hashExpr(const EncodedFormula& expr) const { ostringstream serial; serial << expr.size(); for (const encoded_token_t& tok : expr) { serial << " " << tok.id << " " << tok.arity; } return serial.str(); }
static inline int test_expr_reducer(const EncodedFormula& expr, const EncodedFormula& expectedExpr, uint8_t depth) { MeaningDictionary dict = get_meaning_dict(); SchemaEngine schEng(dict); EncodedFormula result = schEng.reduceFormula(expr, depth); if (expectedExpr.size() != result.size()) return EXIT_FAILURE; for (size_t i = 0; i < result.size(); i++) { encoded_token_t expected = expectedExpr[i]; encoded_token_t returned = result[i]; if (expected.id != returned.id || expected.arity != returned.arity) { return EXIT_FAILURE; } } return EXIT_SUCCESS; }