mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
cleanup
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
#include "sls_detector_defs.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "string_utils.h"
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
@ -36,6 +37,14 @@ std::string ToString(const defs::detectorModeType s);
|
||||
std::string ToString(const defs::burstMode s);
|
||||
std::string ToString(const defs::timingSourceType s);
|
||||
|
||||
std::string ToString(const slsDetectorDefs::ROI &roi);
|
||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::ROI &roi);
|
||||
|
||||
template<typename T, size_t Capacity>
|
||||
std::ostream &operator<<(std::ostream &os, const sls::FixedCapacityContainer<T, Capacity>& c){
|
||||
return os << ToString(c);
|
||||
}
|
||||
|
||||
const std::string &ToString(const std::string &s);
|
||||
|
||||
/** Convert std::chrono::duration with specified output unit */
|
||||
|
@ -2,6 +2,16 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
std::string ToString(const slsDetectorDefs::ROI& roi){
|
||||
std::ostringstream oss;
|
||||
oss << '[' << roi.xmin << ", " << roi.xmax << ']';
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::ostream&operator<<(std::ostream &os, const slsDetectorDefs::ROI& roi){
|
||||
return os << ToString(roi);
|
||||
}
|
||||
|
||||
std::string ToString(const defs::runStatus s) {
|
||||
switch (s) {
|
||||
case defs::ERROR:
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
// using namespace sls;
|
||||
using sls::defs;
|
||||
@ -216,4 +217,35 @@ TEST_CASE("Detector type") {
|
||||
auto dt = defs::detectorType::EIGER;
|
||||
REQUIRE(ToString(dt) == "Eiger");
|
||||
REQUIRE(StringTo<defs::detectorType>("Eiger") == dt);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Formatting slsDetectorDefs::ROI"){
|
||||
slsDetectorDefs::ROI roi{5,159};
|
||||
REQUIRE(ToString(roi) == "[5, 159]");
|
||||
}
|
||||
|
||||
TEST_CASE("Streaming of slsDetectorDefs::ROI"){
|
||||
using namespace sls;
|
||||
slsDetectorDefs::ROI roi{-10,1};
|
||||
std::ostringstream oss;
|
||||
oss << roi;
|
||||
REQUIRE(oss.str() == "[-10, 1]");
|
||||
}
|
||||
|
||||
TEST_CASE("sls::FixedCapacityContainer"){
|
||||
sls::FixedCapacityContainer<int, 5> vec;
|
||||
vec.push_back(3);
|
||||
vec.push_back(8);
|
||||
REQUIRE(ToString(vec) == "[3, 8]");
|
||||
}
|
||||
|
||||
TEST_CASE("sls::FixedCapacityContainer stream"){
|
||||
sls::FixedCapacityContainer<int, 5> vec;
|
||||
vec.push_back(33);
|
||||
vec.push_back(85667);
|
||||
vec.push_back(2);
|
||||
std::ostringstream oss;
|
||||
oss << vec;
|
||||
REQUIRE(oss.str() == "[33, 85667, 2]");
|
||||
}
|
Reference in New Issue
Block a user