- formatting implemented for floating point types
- fixed some bugs with width and precision specifiers:
* Evaluation order of nested replacement fields
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#ifndef FENNEC_TEST_PRINTING_H
|
||||
#define FENNEC_TEST_PRINTING_H
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
#include <fennec/filesystem/path.h>
|
||||
@@ -63,17 +64,17 @@ inline std::ostream& operator<<(std::ostream& os, const quaternion<ScalarT>& q)
|
||||
|
||||
// Helper for printing strings
|
||||
inline std::ostream& operator<<(std::ostream& os, const cstring& str) {
|
||||
return os << str.data();
|
||||
return os << std::quoted(str.data());
|
||||
}
|
||||
|
||||
// Helper for printing strings
|
||||
inline std::ostream& operator<<(std::ostream& os, const string& str) {
|
||||
return os << str.cstr();
|
||||
return os << std::quoted(str.cstr());
|
||||
}
|
||||
|
||||
// Helper for printing strings
|
||||
inline std::ostream& operator<<(std::ostream& os, const path& str) {
|
||||
return os << str.str();
|
||||
return os << std::quoted(str.cstr());
|
||||
}
|
||||
|
||||
// Helper for printing types
|
||||
|
||||
@@ -83,6 +83,22 @@ inline void fennec_test_format() {
|
||||
|
||||
fennec_test_run(fennec::format("{},{}", true, false), string("true,false"));
|
||||
fennec_test_run(fennec::format("{:#06b},{:#06b}", true, false), string("0b0001,0b0000"));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(fennec::format("{:10f}", fennec::pi<float>()), string(" 3.141593"));
|
||||
fennec_test_run(fennec::format("{:{}f}", fennec::pi<float>(), 10), string(" 3.141593"));
|
||||
fennec_test_run(fennec::format("{:.5f}", fennec::pi<float>()), string("3.14159"));
|
||||
fennec_test_run(fennec::format("{:.{}f}", fennec::pi<float>(), 5), string("3.14159"));
|
||||
fennec_test_run(fennec::format("{:10.5f}", fennec::pi<float>()), string(" 3.14159"));
|
||||
fennec_test_run(fennec::format("{:{}.{}f}", fennec::pi<float>(), 10, 5), string(" 3.14159"));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(fennec::format("{:.5f}", fennec::pi<float>()), string("3.14159"));
|
||||
fennec_test_run(fennec::format("{:.5a}", fennec::pi<float>()), string("1.921fbp+1"));
|
||||
fennec_test_run(fennec::format("{:.5g}", fennec::pi<float>()), string("3.1416"));
|
||||
fennec_test_run(fennec::format("{:.5e}", fennec::pi<float>()), string("3.14159e+00"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user