mirror of
https://github.com/gwm17/catima.git
synced 2024-11-23 02:38:51 -05:00
added storage tests
This commit is contained in:
parent
56cb0f0d2f
commit
00663abfa3
|
@ -122,7 +122,7 @@ namespace catima{
|
|||
~Data();
|
||||
void Add(const Projectile &p, const Material &t, Config c=default_config);
|
||||
int GetN() const {return storage.size();};
|
||||
void Reset(){storage.clear();storage.resize(max_storage_data);};
|
||||
void Reset(){storage.clear();storage.resize(max_storage_data);index=storage.begin();};
|
||||
DataPoint& Get(const Projectile &p, const Material &t, Config c=default_config);
|
||||
int get_index() {return std::distance(storage.begin(),index);}
|
||||
private:
|
||||
|
|
|
@ -4,7 +4,17 @@ using namespace std;
|
|||
|
||||
#include "catima/catima.h"
|
||||
#include "catima/storage.h"
|
||||
#include "catima/material_database.h"
|
||||
|
||||
bool rcompare(double a, double b,double eps){
|
||||
if(fabs((a-b)/fabs(b))<eps){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
std::cout<<"\033[1;31m"<<a<<" == "<<b<<"\033[0m"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const lest::test specification[] =
|
||||
{
|
||||
|
@ -61,10 +71,33 @@ const lest::test specification[] =
|
|||
catima::_storage.Add(p,graphite);
|
||||
EXPECT(catima::_storage.get_index()==2);
|
||||
},
|
||||
CASE("storage limit"){
|
||||
for(int i=0;i<100;i++){
|
||||
auto m = catima::get_material(i);
|
||||
CASE("test maximum storage"){ // this test assumes max storage = 50
|
||||
catima::Projectile p{12,6,6,1000};
|
||||
catima::Material water({
|
||||
{1,1,2},
|
||||
{16,8,1}
|
||||
});
|
||||
|
||||
catima::Material graphite({
|
||||
{12,6,1}
|
||||
});
|
||||
catima::_storage.Reset();
|
||||
EXPECT(catima::_storage.get_index()==0);
|
||||
for(int i=1;i<51;i++){
|
||||
catima::Projectile p1{2*i,i,i,1000};
|
||||
catima::_storage.Add(p1,graphite);
|
||||
EXPECT(catima::_storage.get_index()==i);
|
||||
EXPECT(catima::_storage.GetN()==50);
|
||||
}
|
||||
EXPECT(catima::_storage.get_index()==50);
|
||||
for(int i=1;i<49;i++){
|
||||
catima::Projectile p1{2*i,i,i,1000};
|
||||
catima::_storage.Add(p1,water);
|
||||
EXPECT(catima::_storage.get_index()==i);
|
||||
EXPECT(catima::_storage.GetN()==50);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
CASE("energy table"){
|
||||
double step = (catima::logEmax - catima::logEmin)/(catima::max_datapoints-1);
|
||||
|
|
Loading…
Reference in New Issue
Block a user