From 1ee78ab20c335c27ceb6e68829bdbc21ddc12add Mon Sep 17 00:00:00 2001 From: Cameron White Date: Wed, 8 Jul 2020 18:11:58 -0400 Subject: [PATCH] Fix a number of MSVC warnings. - Fixed many size_t conversion warnings - Used enum class for FilterRule::Subject and FilterRule::Operation to fix intellisense warnings. --- source/actions/addinstrument.cpp | 2 +- source/actions/addplayer.cpp | 2 +- source/actions/editviewfilters.cpp | 5 +- source/app/scorearea.cpp | 2 +- source/dialogs/directiondialog.cpp | 7 ++- source/dialogs/filterrulewidget.cpp | 15 ++--- source/dialogs/viewfilterdialog.cpp | 7 ++- source/dialogs/viewfilterpresenter.cpp | 2 +- source/formats/gp7/converter.cpp | 10 ++-- source/formats/gp7/parser.cpp | 10 ++-- .../formats/guitar_pro/gp345to7converter.cpp | 16 +++--- source/midi/midifile.cpp | 4 +- source/score/score.cpp | 10 ++-- source/score/utils/scoremerger.cpp | 6 +- source/score/viewfilter.cpp | 55 ++++++++++--------- source/score/viewfilter.h | 36 ++++++------ test/actions/test_editviewfilters.cpp | 7 ++- test/dialogs/test_viewfilterdialog.cpp | 3 +- test/score/test_score.cpp | 4 +- test/score/test_viewfilter.cpp | 18 +++--- 20 files changed, 118 insertions(+), 103 deletions(-) diff --git a/source/actions/addinstrument.cpp b/source/actions/addinstrument.cpp index 63bac7cc6..125ed361e 100644 --- a/source/actions/addinstrument.cpp +++ b/source/actions/addinstrument.cpp @@ -23,7 +23,7 @@ AddInstrument::AddInstrument(Score &score, const Instrument &instrument) : QUndoCommand(QObject::tr("Add Instrument")), myScore(score), myInstrument(instrument), - myIndex(score.getInstruments().size()) + myIndex(static_cast(score.getInstruments().size())) { } diff --git a/source/actions/addplayer.cpp b/source/actions/addplayer.cpp index 0feb962ba..1ffc28245 100644 --- a/source/actions/addplayer.cpp +++ b/source/actions/addplayer.cpp @@ -23,7 +23,7 @@ AddPlayer::AddPlayer(Score &score, const Player &player) : QUndoCommand(QObject::tr("Add Player")), myScore(score), myPlayer(player), - myPlayerIndex(score.getPlayers().size()) + myPlayerIndex(static_cast(score.getPlayers().size())) { } diff --git a/source/actions/editviewfilters.cpp b/source/actions/editviewfilters.cpp index 3d46ea84e..3a0c3338a 100644 --- a/source/actions/editviewfilters.cpp +++ b/source/actions/editviewfilters.cpp @@ -42,7 +42,10 @@ void EditViewFilters::undo() void EditViewFilters::setViewFilters(const std::vector &filters) { while (!myScore.getViewFilters().empty()) - myScore.removeViewFilter(myScore.getViewFilters().size() - 1); + { + myScore.removeViewFilter( + static_cast(myScore.getViewFilters().size()) - 1); + } for (const ViewFilter &filter : filters) myScore.insertViewFilter(filter); diff --git a/source/app/scorearea.cpp b/source/app/scorearea.cpp index c6df8919f..b8d870fa7 100644 --- a/source/app/scorearea.cpp +++ b/source/app/scorearea.cpp @@ -73,7 +73,7 @@ void ScoreArea::renderDocument(const Document &document) myScoreInfoBlock = ScoreInfoRenderer::render(score.getScoreInfo(), activePalette->text().color()); - myRenderedSystems.reserve(score.getSystems().size()); + myRenderedSystems.reserve(static_cast(score.getSystems().size())); for (unsigned int i = 0; i < score.getSystems().size(); ++i) myRenderedSystems.append(nullptr); diff --git a/source/dialogs/directiondialog.cpp b/source/dialogs/directiondialog.cpp index fed0c881f..09e49ffde 100644 --- a/source/dialogs/directiondialog.cpp +++ b/source/dialogs/directiondialog.cpp @@ -97,7 +97,8 @@ void DirectionDialog::onAddDirection() ui->directionComboBox->addItem( QString::number(myDirection.getSymbols().size())); - ui->directionComboBox->setCurrentIndex(myDirection.getSymbols().size() - 1); + ui->directionComboBox->setCurrentIndex( + static_cast(myDirection.getSymbols().size()) - 1); if (myDirection.getSymbols().size() == MAX_SYMBOLS) ui->addDirectionButton->setDisabled(true); @@ -116,8 +117,8 @@ void DirectionDialog::onRemoveDirection() for (unsigned long i = 0; i < myDirection.getSymbols().size(); ++i) ui->directionComboBox->addItem(QString::number(i + 1)); - ui->directionComboBox->setCurrentIndex( - std::min(index, myDirection.getSymbols().size() - 1)); + ui->directionComboBox->setCurrentIndex(std::min( + index, static_cast(myDirection.getSymbols().size()) - 1)); // Update the Add/Remove buttons. ui->addDirectionButton->setEnabled(true); diff --git a/source/dialogs/filterrulewidget.cpp b/source/dialogs/filterrulewidget.cpp index a3cd92497..3879b4852 100644 --- a/source/dialogs/filterrulewidget.cpp +++ b/source/dialogs/filterrulewidget.cpp @@ -37,10 +37,11 @@ class StringFilterValidator : public QValidator // Verify that the filter is valid. try { - FilterRule rule(FilterRule::PLAYER_NAME, input.toStdString()); + FilterRule rule(FilterRule::Subject::PlayerName, + input.toStdString()); return State::Acceptable; } - catch (const std::exception &e) + catch (const std::exception &) { return State::Intermediate; } @@ -93,12 +94,12 @@ FilterRuleWidget::~FilterRuleWidget() void FilterRuleWidget::update(const FilterRule &rule) { - ui->subjectComboBox->setCurrentIndex(rule.getSubject()); - ui->stackedWidget->setCurrentIndex(rule.getSubject()); + ui->subjectComboBox->setCurrentIndex(int(rule.getSubject())); + ui->stackedWidget->setCurrentIndex(int(rule.getSubject())); ui->regexLineEdit->setText(QString::fromStdString(rule.getStringValue())); - ui->operationComboBox->setCurrentIndex(rule.getOperation()); + ui->operationComboBox->setCurrentIndex(int(rule.getOperation())); ui->stringsSpinBox->setValue(rule.getIntValue()); } @@ -108,13 +109,13 @@ void FilterRuleWidget::updateRule() { if (ui->regexLineEdit->hasAcceptableInput()) { - emit changed(FilterRule(FilterRule::PLAYER_NAME, + emit changed(FilterRule(FilterRule::Subject::PlayerName, ui->regexLineEdit->text().toStdString())); } } else { - emit changed(FilterRule(FilterRule::NUM_STRINGS, + emit changed(FilterRule(FilterRule::Subject::NumStrings, static_cast( ui->operationComboBox->currentIndex()), ui->stringsSpinBox->value())); diff --git a/source/dialogs/viewfilterdialog.cpp b/source/dialogs/viewfilterdialog.cpp index a9e55ac6b..78bb5ab93 100644 --- a/source/dialogs/viewfilterdialog.cpp +++ b/source/dialogs/viewfilterdialog.cpp @@ -102,8 +102,9 @@ void ViewFilterDialog::update(const std::vector &names, ui->nameLineEdit->setText(QString::fromStdString(names[*selection])); // Add new widgets if necessary. - for (size_t i = ui->filterRuleLayout->count(), n = rules.size(); i < n; - ++i) + for (int i = ui->filterRuleLayout->count(), + n = static_cast(rules.size()); + i < n; ++i) { auto widget = new FilterRuleWidget(this); ui->filterRuleLayout->addWidget(widget); @@ -118,7 +119,7 @@ void ViewFilterDialog::update(const std::vector &names, } // Update widgets. - for (size_t i = 0, n = rules.size(); i < n; ++i) + for (int i = 0, n = static_cast(rules.size()); i < n; ++i) { auto widget = dynamic_cast( ui->filterRuleLayout->itemAt(i)->widget()); diff --git a/source/dialogs/viewfilterpresenter.cpp b/source/dialogs/viewfilterpresenter.cpp index 6191ee394..08469b168 100644 --- a/source/dialogs/viewfilterpresenter.cpp +++ b/source/dialogs/viewfilterpresenter.cpp @@ -59,7 +59,7 @@ void ViewFilterPresenter::removeSelectedFilter() if (myFilters.empty()) mySelection.reset(); else if (*mySelection == static_cast(myFilters.size())) - *mySelection = myFilters.size() - 1; + *mySelection = static_cast(myFilters.size()) - 1; updateView(); } diff --git a/source/formats/gp7/converter.cpp b/source/formats/gp7/converter.cpp index c3deb26ad..b5aca455f 100644 --- a/source/formats/gp7/converter.cpp +++ b/source/formats/gp7/converter.cpp @@ -75,7 +75,7 @@ convertPlayers(const std::vector &tracks, Score &score, for (const Gp7::Track &track : tracks) { assert(!track.mySounds.empty()); - const int instrument_idx = score.getInstruments().size(); + const int instrument_idx = static_cast(score.getInstruments().size()); for (const Gp7::Sound &sound : track.mySounds) { @@ -103,7 +103,7 @@ convertPlayers(const std::vector &tracks, Score &score, tuning.setCapo(staff.myCapo); player.setTuning(tuning); - const int player_idx = score.getPlayers().size(); + const int player_idx = static_cast(score.getPlayers().size()); score.insertPlayer(player); // Each player will be assigned its own staff, and is initially @@ -946,7 +946,7 @@ convertSystem(const Gp7::Document &doc, Score &score, int bar_begin, int system_bar_idx = 0; for (int bar_idx = bar_begin; bar_idx < bar_end; ++bar_idx) { - const int num_staves = score.getPlayers().size(); + const int num_staves = static_cast(score.getPlayers().size()); const Gp7::MasterBar &master_bar = doc.myMasterBars.at(bar_idx); // If the previous bar was a repeat end, and this master bar is a @@ -1108,11 +1108,11 @@ Gp7::convert(const Gp7::Document &doc, Score &score) // The multi-track layout is sometimes invalid (particularly for .gpx // files). So, fall back to the first track's layout if we need to. std::vector layout = doc.myScoreInfo.myScoreSystemsLayout; - if (!isValidLayout(layout, doc.myMasterBars.size()) && + if (!isValidLayout(layout, static_cast(doc.myMasterBars.size())) && !doc.myTracks.empty()) { layout = doc.myTracks[0].mySystemsLayout; - assert(isValidLayout(layout, doc.myMasterBars.size())); + assert(isValidLayout(layout, static_cast(doc.myMasterBars.size()))); } int bar_idx = 0; diff --git a/source/formats/gp7/parser.cpp b/source/formats/gp7/parser.cpp index 151073d5a..62a70f2c1 100644 --- a/source/formats/gp7/parser.cpp +++ b/source/formats/gp7/parser.cpp @@ -754,7 +754,7 @@ parseRhythms(const pugi::xml_node &rhythms_node) void Gp7::Document::addBar(MasterBar &master_bar, Bar bar) { - const int bar_id = myBars.size(); + const int bar_id = static_cast(myBars.size()); myBars[bar_id] = std::move(bar); master_bar.myBarIds.push_back(bar_id); } @@ -762,7 +762,7 @@ Gp7::Document::addBar(MasterBar &master_bar, Bar bar) void Gp7::Document::addVoice(Bar &bar, Voice voice) { - const int voice_id = myVoices.size(); + const int voice_id = static_cast(myVoices.size()); myVoices[voice_id] = std::move(voice); bar.myVoiceIds.push_back(voice_id); } @@ -770,7 +770,7 @@ Gp7::Document::addVoice(Bar &bar, Voice voice) void Gp7::Document::addBeat(Voice &voice, Beat beat) { - const int beat_id = myBeats.size(); + const int beat_id = static_cast(myBeats.size()); myBeats[beat_id] = std::move(beat); voice.myBeatIds.push_back(beat_id); } @@ -778,7 +778,7 @@ Gp7::Document::addBeat(Voice &voice, Beat beat) void Gp7::Document::addNote(Beat &beat, Note note) { - const int note_id = myNotes.size(); + const int note_id = static_cast(myNotes.size()); myNotes[note_id] = std::move(note); beat.myNoteIds.push_back(note_id); } @@ -787,7 +787,7 @@ void Gp7::Document::addRhythm(Beat &beat, Rhythm rhythm) { // TODO - consolidate identical rhythms? - const int rhythm_id = myRhythms.size(); + const int rhythm_id = static_cast(myRhythms.size()); myRhythms[rhythm_id] = std::move(rhythm); beat.myRhythmId = rhythm_id; } diff --git a/source/formats/guitar_pro/gp345to7converter.cpp b/source/formats/guitar_pro/gp345to7converter.cpp index f474e2412..ff2458705 100644 --- a/source/formats/guitar_pro/gp345to7converter.cpp +++ b/source/formats/guitar_pro/gp345to7converter.cpp @@ -41,8 +41,9 @@ convertScoreInfo(const Gp::Document &doc) // Decide how the measures are split into systems. // For now just do three measures per system. static constexpr int measures_per_system = 3; - const int num_systems = doc.myMeasures.size() / measures_per_system; - const int remainder = doc.myMeasures.size() % measures_per_system; + const int num_measures = static_cast(doc.myMeasures.size()); + const int num_systems = num_measures / measures_per_system; + const int remainder = num_measures % measures_per_system; std::vector &layout = gp7_info.myScoreSystemsLayout; layout.insert(layout.begin(), num_systems, measures_per_system); @@ -91,7 +92,7 @@ convertTracks(const Gp::Document &doc) static int convertStringNumber(const Gp::Track &track, int string) { - return track.myTuning.size() - string - 1; + return static_cast(track.myTuning.size()) - string - 1; } static std::optional @@ -250,8 +251,8 @@ convertBeat(const Gp::Beat &beat, const Gp::Track &track, rhythm.myTupletNum = *beat.myIrregularGrouping; // The denominator of the irregular grouping is the nearest // power of 2 (from below). - rhythm.myTupletDenom = std::pow( - 2, std::floor(std::log(rhythm.myTupletNum) / std::log(2.0))); + rhythm.myTupletDenom = static_cast(std::pow( + 2, std::floor(std::log(rhythm.myTupletNum) / std::log(2.0)))); } gp7_doc.addRhythm(gp7_beat, std::move(rhythm)); @@ -486,8 +487,9 @@ convertMasterBars(const Gp::Document &doc, Gp7::Document &gp7_doc) gp7_doc.addBeat(gp7_voice, std::move(*grace_beat)); Gp7::Beat gp7_beat; - convertBeat(beat, track, gp7_doc, gp7_voice, staff_idx, - voice_idx, gp7_beat); + convertBeat(beat, track, gp7_doc, gp7_voice, + static_cast(staff_idx), + static_cast(voice_idx), gp7_beat); gp7_doc.addBeat(gp7_voice, std::move(gp7_beat)); // Add tempo changes to the measure. diff --git a/source/midi/midifile.cpp b/source/midi/midifile.cpp index fa6d30786..c6bd509f7 100644 --- a/source/midi/midifile.cpp +++ b/source/midi/midifile.cpp @@ -339,7 +339,7 @@ findNextTempoMarker(const Score &score, SystemLocation location, MidiEventList event_list; const int current_tick = -1; - const int num_systems = score.getSystems().size(); + const int num_systems = static_cast(score.getSystems().size()); while (location.getSystem() < num_systems) { const System &system = score.getSystems()[location.getSystem()]; @@ -416,7 +416,7 @@ MidiFile::addTempoEvent(MidiEventList &event_list, int current_tick, // We're working in microseconds, so a tempo change event every // millisecond seems reasonable ... - const int num_events = std::abs(delta_tempo.count()) / 1000; + const int num_events = static_cast(std::abs(delta_tempo.count()) / 1000); if (!num_events) return current_tempo; diff --git a/source/score/score.cpp b/source/score/score.cpp index 144e2516a..c1fd7d075 100644 --- a/source/score/score.cpp +++ b/source/score/score.cpp @@ -220,13 +220,15 @@ void ScoreUtils::addStandardFilters(Score &score) ViewFilter filter_guitars; filter_guitars.setDescription("Guitars"); - filter_guitars.addRule( - FilterRule(FilterRule::NUM_STRINGS, FilterRule::GREATER_THAN_EQUAL, 6)); + filter_guitars.addRule(FilterRule(FilterRule::Subject::NumStrings, + FilterRule::Operation::GreaterThanEqual, + 6)); score.insertViewFilter(filter_guitars); ViewFilter filter_basses; filter_basses.setDescription("Basses"); - filter_basses.addRule( - FilterRule(FilterRule::NUM_STRINGS, FilterRule::LESS_THAN_EQUAL, 5)); + filter_basses.addRule(FilterRule(FilterRule::Subject::NumStrings, + FilterRule::Operation::LessThanEqual, + 5)); score.insertViewFilter(filter_basses); } diff --git a/source/score/utils/scoremerger.cpp b/source/score/utils/scoremerger.cpp index 31f5eca53..f52ff9784 100644 --- a/source/score/utils/scoremerger.cpp +++ b/source/score/utils/scoremerger.cpp @@ -588,9 +588,9 @@ static bool areStavesIncompatible( { return areStavesIncompatible(dest_loc, guitar_caret, guitar_bar, end_guitar_bar, 0, num_guitar_staves) || - areStavesIncompatible(dest_loc, bass_caret, bass_bar, end_bass_bar, - num_guitar_staves, - dest_loc.getSystem().getStaves().size()); + areStavesIncompatible( + dest_loc, bass_caret, bass_bar, end_bass_bar, num_guitar_staves, + static_cast(dest_loc.getSystem().getStaves().size())); } static void insertNewSystem(Score &score) diff --git a/source/score/viewfilter.cpp b/source/score/viewfilter.cpp index ccd0a21ea..2b68861f8 100644 --- a/source/score/viewfilter.cpp +++ b/source/score/viewfilter.cpp @@ -31,15 +31,15 @@ struct FilterRule::RegexImpl }; FilterRule::FilterRule() - : mySubject(Subject::PLAYER_NAME), - myOperation(Operation::EQUAL), + : mySubject(Subject::PlayerName), + myOperation(Operation::Equal), myIntValue(0) { } FilterRule::FilterRule(Subject subject, std::string value) : mySubject(subject), - myOperation(Operation::EQUAL), + myOperation(Operation::Equal), myIntValue(0), myStrValue(std::move(value)), myRegexImpl(std::make_unique(myStrValue)) @@ -82,32 +82,33 @@ bool FilterRule::accept(const Player &player) const { switch (mySubject) { - case PLAYER_NAME: - return std::regex_match(player.getDescription(), myRegexImpl->myRegex); - case NUM_STRINGS: - { - const int value = player.getTuning().getStringCount(); - - switch (myOperation) + case Subject::PlayerName: + return std::regex_match(player.getDescription(), + myRegexImpl->myRegex); + case Subject::NumStrings: { - case LESS_THAN: - return value < myIntValue; - case LESS_THAN_EQUAL: - return value <= myIntValue; - case EQUAL: - return value == myIntValue; - case GREATER_THAN: - return value > myIntValue; - case GREATER_THAN_EQUAL: - return value >= myIntValue; - } + const int value = player.getTuning().getStringCount(); - assert(false); - return false; - } - default: - assert(!"Unexpected subject for filter."); - return false; + switch (myOperation) + { + case Operation::LessThan: + return value < myIntValue; + case Operation::LessThanEqual: + return value <= myIntValue; + case Operation::Equal: + return value == myIntValue; + case Operation::GreaterThan: + return value > myIntValue; + case Operation::GreaterThanEqual: + return value >= myIntValue; + } + + assert(false); + return false; + } + default: + assert(!"Unexpected subject for filter."); + return false; } } diff --git a/source/score/viewfilter.h b/source/score/viewfilter.h index 1c9e90f86..85d3fcb61 100644 --- a/source/score/viewfilter.h +++ b/source/score/viewfilter.h @@ -34,19 +34,19 @@ class Score; class FilterRule { public: - enum Subject : int + enum class Subject : int { - PLAYER_NAME = 0, - NUM_STRINGS = 1, + PlayerName = 0, + NumStrings = 1, }; - enum Operation : int + enum class Operation : int { - LESS_THAN = 0, - LESS_THAN_EQUAL = 1, - EQUAL = 2, - GREATER_THAN_EQUAL = 3, - GREATER_THAN = 4 + LessThan = 0, + LessThanEqual = 1, + Equal = 2, + GreaterThanEqual = 3, + GreaterThan = 4 }; FilterRule(); @@ -132,15 +132,15 @@ void FilterRule::serialize(Archive &ar, const FileVersion /*version*/) switch (mySubject) { - case PLAYER_NAME: - ar("value", myStrValue); - break; - case NUM_STRINGS: - ar("value", myIntValue); - break; - default: - assert(!"Unexpected subject for filter."); - break; + case Subject::PlayerName: + ar("value", myStrValue); + break; + case Subject::NumStrings: + ar("value", myIntValue); + break; + default: + assert(!"Unexpected subject for filter."); + break; } } diff --git a/test/actions/test_editviewfilters.cpp b/test/actions/test_editviewfilters.cpp index 060c308d8..250452155 100644 --- a/test/actions/test_editviewfilters.cpp +++ b/test/actions/test_editviewfilters.cpp @@ -25,10 +25,11 @@ TEST_CASE("Actions/EditViewFilters") Score score; ViewFilter filter1; - filter1.addRule(FilterRule(FilterRule::NUM_STRINGS, FilterRule::EQUAL, 7)); + filter1.addRule(FilterRule(FilterRule::Subject::NumStrings, + FilterRule::Operation::Equal, 7)); ViewFilter filter2; - filter2.addRule( - FilterRule(FilterRule::NUM_STRINGS, FilterRule::LESS_THAN_EQUAL, 5)); + filter2.addRule(FilterRule(FilterRule::Subject::NumStrings, + FilterRule::Operation::LessThanEqual, 5)); score.insertViewFilter(filter2); diff --git a/test/dialogs/test_viewfilterdialog.cpp b/test/dialogs/test_viewfilterdialog.cpp index 1241316e8..158fb3ba3 100644 --- a/test/dialogs/test_viewfilterdialog.cpp +++ b/test/dialogs/test_viewfilterdialog.cpp @@ -146,7 +146,8 @@ TEST_CASE("Dialogs/ViewFilter") { presenter.addRule(); - FilterRule new_rule(FilterRule::NUM_STRINGS, FilterRule::EQUAL, 4); + FilterRule new_rule(FilterRule::Subject::NumStrings, + FilterRule::Operation::Equal, 4); presenter.editRule(0, new_rule); REQUIRE(view.myRules[0] == new_rule); REQUIRE(view.myMatches == std::vector{ bass.getDescription() }); diff --git a/test/score/test_score.cpp b/test/score/test_score.cpp index 31aa23182..2f550164c 100644 --- a/test/score/test_score.cpp +++ b/test/score/test_score.cpp @@ -67,11 +67,11 @@ TEST_CASE("Score/Score/ViewFilters") REQUIRE(score.getViewFilters().size() == 0); ViewFilter filter1; - filter1.addRule(FilterRule(FilterRule::PLAYER_NAME, "foo")); + filter1.addRule(FilterRule(FilterRule::Subject::PlayerName, "foo")); score.insertViewFilter(filter1); ViewFilter filter2; - filter2.addRule(FilterRule(FilterRule::PLAYER_NAME, "bar")); + filter2.addRule(FilterRule(FilterRule::Subject::PlayerName, "bar")); score.insertViewFilter(filter2); REQUIRE(score.getViewFilters().size() == 2); diff --git a/test/score/test_viewfilter.cpp b/test/score/test_viewfilter.cpp index d0a551999..c8839a20f 100644 --- a/test/score/test_viewfilter.cpp +++ b/test/score/test_viewfilter.cpp @@ -30,12 +30,13 @@ TEST_CASE("Score/ViewFilter/FilterRule") PowerTabImporter importer; importer.load(AppInfo::getAbsolutePath("data/test_viewfilter.pt2"), score); - FilterRule rule(FilterRule::NUM_STRINGS, FilterRule::EQUAL, 7); + FilterRule rule(FilterRule::Subject::NumStrings, + FilterRule::Operation::Equal, 7); REQUIRE(!rule.accept(score.getPlayers()[0])); REQUIRE(rule.accept(score.getPlayers()[1])); REQUIRE(!rule.accept(score.getPlayers()[2])); - rule = FilterRule(FilterRule::PLAYER_NAME, "Player [12]"); + rule = FilterRule(FilterRule::Subject::PlayerName, "Player [12]"); REQUIRE(rule.accept(score.getPlayers()[0])); REQUIRE(rule.accept(score.getPlayers()[1])); REQUIRE(!rule.accept(score.getPlayers()[2])); @@ -49,9 +50,10 @@ TEST_CASE("Score/ViewFilter/ViewFilter") importer.load(AppInfo::getAbsolutePath("data/test_viewfilter.pt2"), score); ViewFilter filter; - filter.addRule(FilterRule(FilterRule::NUM_STRINGS, FilterRule::EQUAL, 7)); - filter.addRule( - FilterRule(FilterRule::NUM_STRINGS, FilterRule::LESS_THAN_EQUAL, 5)); + filter.addRule(FilterRule(FilterRule::Subject::NumStrings, + FilterRule::Operation::Equal, 7)); + filter.addRule(FilterRule(FilterRule::Subject::NumStrings, + FilterRule::Operation::LessThanEqual, 5)); REQUIRE(!filter.accept(score, 0, 0)); REQUIRE(filter.accept(score, 0, 1)); @@ -61,9 +63,9 @@ TEST_CASE("Score/ViewFilter/ViewFilter") TEST_CASE("Score/ViewFilter/Serialization") { ViewFilter filter; - filter.addRule( - FilterRule(FilterRule::NUM_STRINGS, FilterRule::LESS_THAN, 5)); - filter.addRule(FilterRule(FilterRule::PLAYER_NAME, "foo")); + filter.addRule(FilterRule(FilterRule::Subject::NumStrings, + FilterRule::Operation::LessThan, 5)); + filter.addRule(FilterRule(FilterRule::Subject::PlayerName, "foo")); Serialization::test("filter", filter); }