mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Add missing stream ops (flutter/engine#37034)
This commit is contained in:
parent
4572923236
commit
702a9365bd
@ -1616,32 +1616,94 @@ TEST(GeometryTest, VerticesConstructorAndGetters) {
|
||||
}
|
||||
|
||||
TEST(GeometryTest, MatrixPrinting) {
|
||||
std::stringstream stream;
|
||||
|
||||
Matrix m;
|
||||
|
||||
stream << m;
|
||||
|
||||
ASSERT_EQ(stream.str(), R"((
|
||||
{
|
||||
std::stringstream stream;
|
||||
Matrix m;
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), R"((
|
||||
1.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 1.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 1.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 1.000000,
|
||||
))");
|
||||
}
|
||||
|
||||
stream.str("");
|
||||
stream.clear();
|
||||
{
|
||||
std::stringstream stream;
|
||||
Matrix m = Matrix::MakeTranslation(Vector3(10, 20, 30));
|
||||
stream << m;
|
||||
|
||||
m = Matrix::MakeTranslation(Vector3(10, 20, 30));
|
||||
|
||||
stream << m;
|
||||
|
||||
ASSERT_EQ(stream.str(), R"((
|
||||
ASSERT_EQ(stream.str(), R"((
|
||||
1.000000, 0.000000, 0.000000, 10.000000,
|
||||
0.000000, 1.000000, 0.000000, 20.000000,
|
||||
0.000000, 0.000000, 1.000000, 30.000000,
|
||||
0.000000, 0.000000, 0.000000, 1.000000,
|
||||
))");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GeometryTest, PointPrinting) {
|
||||
{
|
||||
std::stringstream stream;
|
||||
Point m;
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), "(0, 0)");
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream stream;
|
||||
Point m(13, 37);
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), "(13, 37)");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GeometryTest, Vector3Printing) {
|
||||
{
|
||||
std::stringstream stream;
|
||||
Vector3 m;
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), "(0, 0, 0)");
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream stream;
|
||||
Vector3 m(1, 2, 3);
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), "(1, 2, 3)");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GeometryTest, Vector4Printing) {
|
||||
{
|
||||
std::stringstream stream;
|
||||
Vector4 m;
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), "(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream stream;
|
||||
Vector4 m(1, 2, 3, 4);
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), "(1, 2, 3, 4)");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GeometryTest, ColorPrinting) {
|
||||
{
|
||||
std::stringstream stream;
|
||||
Color m;
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), "(0, 0, 0, 0)");
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream stream;
|
||||
Color m(1, 2, 3, 4);
|
||||
stream << m;
|
||||
ASSERT_EQ(stream.str(), "(1, 2, 3, 4)");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GeometryTest, Gradient) {
|
||||
|
||||
@ -247,3 +247,17 @@ static_assert(sizeof(Vector3) == 3 * sizeof(Scalar));
|
||||
static_assert(sizeof(Vector4) == 4 * sizeof(Scalar));
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
namespace std {
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const impeller::Vector3& p) {
|
||||
out << "(" << p.x << ", " << p.y << ", " << p.z << ")";
|
||||
return out;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const impeller::Vector4& p) {
|
||||
out << "(" << p.x << ", " << p.y << ", " << p.z << ", " << p.w << ")";
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user