Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbashford committed Jul 18, 2019
1 parent e2b9d91 commit 2286340
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/av-speech-in-noise/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ namespace av_speech_in_noise {
int startingSnr_dB;
int ceilingSnr_dB;
int floorSnr_dB;
int trackBumpLimit;
};

struct FixedLevelTest {
Expand Down
8 changes: 8 additions & 0 deletions src/google-tests/PresenterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ namespace av_speech_in_noise::tests::presentation {
assertPassesFloorSNR(confirmingAdaptiveOpenSetTest);
}

TEST_F(PresenterTests, confirmingAdaptiveClosedSetTestPassesTrackBumpLimit) {
assertPassesTrackBumpLimit(confirmingAdaptiveClosedSetTest);
}

TEST_F(PresenterTests, confirmingAdaptiveOpenSetTestPassesTrackBumpLimit) {
assertPassesTrackBumpLimit(confirmingAdaptiveOpenSetTest);
}

TEST_F(PresenterTests, confirmingAdaptiveClosedSetTestPassesFullScaleLevel) {
assertPassesFullScaleLevel(confirmingAdaptiveClosedSetTest);
}
Expand Down
21 changes: 21 additions & 0 deletions src/google-tests/PresenterTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ namespace av_speech_in_noise::tests::presentation {
public:
virtual int ceilingSnr_dB(ModelStub &) = 0;
virtual int floorSnr_dB(ModelStub &) = 0;
virtual int trackBumpLimit(ModelStub &) = 0;
virtual std::string trackSettingsFile(ModelStub &) = 0;
};

Expand Down Expand Up @@ -729,6 +730,10 @@ namespace av_speech_in_noise::tests::presentation {
std::string trackSettingsFile(ModelStub &m) override {
return adaptiveTest(m).trackSettingsFile;
}

int trackBumpLimit(ModelStub &m) override {
return adaptiveTest(m).trackBumpLimit;
}
};

void setMethod(ViewStub::TestSetupViewStub *view, Method m) {
Expand Down Expand Up @@ -795,6 +800,10 @@ namespace av_speech_in_noise::tests::presentation {
std::string trackSettingsFile(ModelStub &m) override {
return confirmingAdaptiveTest.trackSettingsFile(m);
}

int trackBumpLimit(ModelStub &m) override {
return confirmingAdaptiveTest.trackBumpLimit(m);
}
};

class ConfirmingAdaptiveOpenSetTest : public ConfirmingAdaptiveTest_ {
Expand Down Expand Up @@ -857,6 +866,10 @@ namespace av_speech_in_noise::tests::presentation {
std::string trackSettingsFile(ModelStub &m) override {
return confirmingAdaptiveTest.trackSettingsFile(m);
}

int trackBumpLimit(ModelStub &m) override {
return confirmingAdaptiveTest.trackBumpLimit(m);
}
};

class ConfirmingFixedLevelTest : public ConfirmingTestSetup {
Expand Down Expand Up @@ -1691,6 +1704,14 @@ namespace av_speech_in_noise::tests::presentation {
);
}

void assertPassesTrackBumpLimit(ConfirmingAdaptiveTest_ &useCase) {
run(useCase);
assertEqual(
Presenter::trackBumpLimit,
useCase.trackBumpLimit(model)
);
}

void assertPassesTrackSettingsFile(ConfirmingAdaptiveTest_ &useCase) {
setupView.setTrackSettingsFile("e");
run(useCase);
Expand Down
2 changes: 2 additions & 0 deletions src/presentation/Presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace av_speech_in_noise {
int Presenter::fullScaleLevel_dB_SPL = 119;
int Presenter::ceilingSnr_dB = 20;
int Presenter::floorSnr_dB = -40;
int Presenter::trackBumpLimit = 10;

Presenter::Presenter(
Model *model,
Expand Down Expand Up @@ -295,6 +296,7 @@ namespace av_speech_in_noise {
p.information = testInformation();
p.ceilingSnr_dB = ceilingSnr_dB;
p.floorSnr_dB = floorSnr_dB;
p.trackBumpLimit = trackBumpLimit;
p.trackSettingsFile = view->trackSettingsFile();
p.common = commonTest();
return p;
Expand Down
1 change: 1 addition & 0 deletions src/presentation/Presenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ namespace av_speech_in_noise {
static int fullScaleLevel_dB_SPL;
static int ceilingSnr_dB;
static int floorSnr_dB;
static int trackBumpLimit;

private:
void proceedToNextTrialAfter(
Expand Down

0 comments on commit 2286340

Please sign in to comment.