test(dobj_sandbox): added some sandbox code for testing dobj
This commit is contained in:
31
tests/dobj_sandbox/testDObject.cpp
Normal file
31
tests/dobj_sandbox/testDObject.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include<iostream>
|
||||
|
||||
#include "DObject.h"
|
||||
|
||||
DObject testFunction(DObject &obj);
|
||||
|
||||
int main(){
|
||||
float data = 55.86868;
|
||||
DObject obj;
|
||||
obj.setData(data);
|
||||
float newData;
|
||||
newData = std::get<float>(obj.getData());
|
||||
std::cout << "Data: " << newData << std::endl;
|
||||
std::cout << "Calling test function" << std::endl;
|
||||
DObject newObj = testFunction(obj);
|
||||
std::cout << newObj << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Test function which takes a DObject as an argument and
|
||||
// returns new DObject with an vector of 10 elements identical to the input DObject
|
||||
// This should use std::varient and auto to do some degree of type inference
|
||||
DObject testFunction(DObject &obj){
|
||||
float data = obj.getDataAs<float>();
|
||||
std::cout << "Data: " << data << std::endl;
|
||||
std::vector<std::vector<float>> newData(3, std::vector<float>(3, data));
|
||||
DObject newObj(newData);
|
||||
std::cout << obj << std::endl;
|
||||
|
||||
return newObj;
|
||||
}
|
||||
Reference in New Issue
Block a user