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

overpass_api/statements/compare.cc

76 of 77 instrumented lines run by the suite (98.7%) 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)
295418 q : Output_Statement(line_number_), criterion(0), set_comparison(0)
315418 q std::map< std::string, std::string > attributes;
335418 q attributes["from"] = "_";
345418 q attributes["into"] = "_";
365418 q eval_attributes_array(get_name(), attributes, input_attributes);
385418 q input = attributes["from"];
395418 q set_output(attributes["into"]);
43void Compare_Statement::add_statement(Statement* statement, std::string text)
457817 q assure_no_text(text, this->get_name());
477817 q if (!criterion)
485117 q {
495117 q Evaluator* tag_value = dynamic_cast< Evaluator* >(statement);
505117 q if (tag_value)
514816 q {
524816 q criterion = tag_value;
534816 q return;
544816 q }
555117 q }
57309 q if (statement->get_name() == "newer")
580 add_static_error("\"newer\" can appear only inside \"query\" statements.");
60309 q substatements.push_back(statement);
64void Compare_Statement::execute(Resource_Manager& rman)
663418 q Diff_Action::_ action = rman.get_desired_action();
683418 q const Set* input_set = rman.get_set(input);
693418 q if (!input_set)
7011 q return;
723317 q if (action == Diff_Action::collect_lhs)
731616 q {
741616 q delete set_comparison;
751616 q set_comparison = new Set_Comparison(
761616 q *rman.get_transaction(), *input_set, rman.get_desired_timestamp());
781616 q Set into;
791616 q transfer_output(rman, into);
801616 q rman.health_check(*this);
811616 q }
821717 q else if (action == Diff_Action::collect_rhs_no_del || action == Diff_Action::collect_rhs_with_del)
831616 q {
841616 q if (criterion)
851515 q {
861515 q Diff_Set into = set_comparison->compare_to_lhs(rman, *this, *input_set,
871515 q criterion, action == Diff_Action::collect_rhs_with_del);
881515 q transfer_output(rman, into);
891515 q }
9011 q else
9211 q Diff_Set into = set_comparison->compare_to_lhs(rman, *this, *input_set,
9311 q 1., 0., 0., 0., action == Diff_Action::collect_rhs_with_del);
9411 q transfer_output(rman, into);
971616 q if (!substatements.empty())
9988 q rman.push_stack_frame();
10088 q rman.switch_diff_show_from(get_result_name());
102178 q for (std::vector< Statement* >::iterator it = substatements.begin(); it != substatements.end(); ++it)
10398 q (*it)->execute(rman);
10588 q rman.pop_stack_frame();
10788 q rman.push_stack_frame();
10888 q rman.switch_diff_show_to(get_result_name());
110178 q for (std::vector< Statement* >::iterator it = substatements.begin(); it != substatements.end(); ++it)
11198 q (*it)->execute(rman);
11388 q rman.pop_stack_frame();
11588 q rman.health_check(*this);
11811 q else
12011 q Set into;
12111 q transfer_output(rman, into);
12211 q rman.health_check(*this);
127Compare_Statement::~Compare_Statement()
1295418 q delete set_comparison;