all of the changes
This commit is contained in:
33
tests/scenario_examples.cpp
Normal file
33
tests/scenario_examples.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "FluidSim/ScenarioCatalog.hpp"
|
||||
#include "FluidSim/DesktopScenario.hpp"
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
using namespace fluidsim::port;
|
||||
int main() {
|
||||
std::set<std::string> ids;
|
||||
for(const auto& example:scenario_examples()) {
|
||||
if(!ids.insert(example.id).second)throw std::runtime_error("duplicate example id");
|
||||
DesktopScenario scenario(example.kind,example.two,example.exhaust,example.v8,example.engine,example.title);
|
||||
scenario.set_audio_scene(OutdoorScene::Dry);
|
||||
const auto started=std::chrono::steady_clock::now();
|
||||
float peak_power=0;
|
||||
for(int i=0;i<88200;++i) {
|
||||
scenario.set_controls(i<44100?.45f:0.f,0,1);
|
||||
const auto audio=scenario.process();
|
||||
if(i%4410==0) peak_power=std::max(peak_power,scenario.snapshot().average_power);
|
||||
if(!std::isfinite(audio.left)||!std::isfinite(audio.right))throw std::runtime_error(example.id+" nonfinite audio");
|
||||
}
|
||||
const auto snapshot=scenario.snapshot();
|
||||
if(snapshot.pipe_positivity_repairs)throw std::runtime_error(example.id+" required positivity repairs");
|
||||
if(example.id=="big-carb" && peak_power<10000)throw std::runtime_error("big carb V8 failed to produce power");
|
||||
if(!std::isfinite(snapshot.rpm)||snapshot.rpm<=0)throw std::runtime_error(example.id+" invalid engine speed");
|
||||
if(example.engine.cylinders && (snapshot.cylinder_count!=example.engine.cylinders || snapshot.layout!=example.engine.layout))throw std::runtime_error("custom cylinder layout lost");
|
||||
if(snapshot.example_name!=example.title)throw std::runtime_error("example name lost");
|
||||
if(example.kind==ScenarioKind::AmericanV8 && snapshot.h_pipe!=example.v8.h_pipe)throw std::runtime_error("example crossover selection lost");
|
||||
if(example.kind==ScenarioKind::SaabB205 && snapshot.silencers!=example.exhaust.enabled)throw std::runtime_error("example silencer selection lost");
|
||||
std::cout<<example.id<<" passed, rpm="<<snapshot.rpm<<", wall/sim="<<std::chrono::duration<double>(std::chrono::steady_clock::now()-started).count()/2<<std::endl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user