Overpass API regression suite coverage (Saxony) / overpass_api/statements/compare.cc

overpass_api/statements/compare.cc

70 of 77 instrumented lines run by the suite (90.9%) at 8edf11b0419c (this file on GitHub).

runnever runcolumns: line, executions, queries (click for the queries that run the line)

1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
2 *
3 * This file is part of Overpass_API.
4 *
5 * Overpass_API is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * Overpass_API is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
17 */
19#include "../data/set_comparison.h"
20#include "evaluator.h"
21#include "compare.h"
24Generic_Statement_Maker< Compare_Statement > Compare_Statement::statement_maker("compare");
27Compare_Statement::Compare_Statement
28 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)
296321 q : Output_Statement(line_number_), criterion(0), set_comparison(0)
316321 q std::map< std::string, std::string > attributes;
336321 q attributes["from"] = "_";
346321 q attributes["into"] = "_";
366321 q eval_attributes_array(get_name(), attributes, input_attributes);
386321 q input = attributes["from"];
396321 q set_output(attributes["into"]);
43void Compare_Statement::add_statement(Statement* statement, std::string text)
459020 q assure_no_text(text, this->get_name());
479020 q if (!criterion)
486020 q {
496020 q Evaluator* tag_value = dynamic_cast< Evaluator* >(statement);
506020 q if (tag_value)
515418 q {
525418 q criterion = tag_value;
535418 q return;
545418 q }
556020 q }
573611 q if (statement->get_name() == "newer")
580 add_static_error("\"newer\" can appear only inside \"query\" statements.");
603611 q substatements.push_back(statement);
64void Compare_Statement::execute(Resource_Manager& rman)
664121 q Diff_Action::_ action = rman.get_desired_action();
684121 q const Set* input_set = rman.get_set(input);
694121 q if (!input_set)
7011 q return;
724020 q if (action == Diff_Action::collect_lhs)
732020 q {
742020 q delete set_comparison;
752020 q set_comparison = new Set_Comparison(
762020 q *rman.get_transaction(), *input_set, rman.get_desired_timestamp());
782020 q Set into;
792020 q transfer_output(rman, into);
802020 q rman.health_check(*this);
812020 q }
822020 q else if (action == Diff_Action::collect_rhs_no_del || action == Diff_Action::collect_rhs_with_del)
832020 q {
842020 q if (criterion)
851717 q {
861717 q Diff_Set into = set_comparison->compare_to_lhs(rman, *this, *input_set,
871717 q criterion, action == Diff_Action::collect_rhs_with_del);
881717 q transfer_output(rman, into);
891717 q }
9033 q else
9233 q Diff_Set into = set_comparison->compare_to_lhs(rman, *this, *input_set,
9333 q 1., 0., 0., 0., action == Diff_Action::collect_rhs_with_del);
9433 q transfer_output(rman, into);
972020 q if (!substatements.empty())
981111 q {
991111 q rman.push_stack_frame();
1001111 q rman.switch_diff_show_from(get_result_name());
1022311 q for (std::vector< Statement* >::iterator it = substatements.begin(); it != substatements.end(); ++it)
1031211 q (*it)->execute(rman);
1051111 q rman.pop_stack_frame();
1071111 q rman.push_stack_frame();
1081111 q rman.switch_diff_show_to(get_result_name());
1102311 q for (std::vector< Statement* >::iterator it = substatements.begin(); it != substatements.end(); ++it)
1111211 q (*it)->execute(rman);
1131111 q rman.pop_stack_frame();
1151111 q rman.health_check(*this);
1180 else
1190 {
1200 Set into;
1210 transfer_output(rman, into);
1220 rman.health_check(*this);
1230 }
127Compare_Statement::~Compare_Statement()
1296321 q delete set_comparison;