[wpimath] Support formatting Eigen array types (#6496)

This commit is contained in:
Tyler Veness
2024-04-04 09:19:50 -07:00
committed by GitHub
parent fbb3669546
commit d26e6d9ecc
2 changed files with 8 additions and 5 deletions

View File

@@ -25,19 +25,22 @@ TEST(FormatterTest, Eigen) {
" 4.000000 5.000000",
fmt::format("{:f}", B));
Eigen::SparseMatrix<double> C{3, 2};
Eigen::Array2d C{0.0, 1.0};
EXPECT_EQ(" 0.000000\n 1.000000", fmt::format("{:f}", C));
Eigen::SparseMatrix<double> D{3, 2};
std::vector<Eigen::Triplet<double>> triplets;
triplets.emplace_back(0, 1, 1.0);
triplets.emplace_back(1, 0, 2.0);
triplets.emplace_back(1, 1, 3.0);
triplets.emplace_back(2, 0, 4.0);
triplets.emplace_back(2, 1, 5.0);
C.setFromTriplets(triplets.begin(), triplets.end());
D.setFromTriplets(triplets.begin(), triplets.end());
EXPECT_EQ(
" 0.000000 1.000000\n"
" 2.000000 3.000000\n"
" 4.000000 5.000000",
fmt::format("{:f}", C));
fmt::format("{:f}", D));
}
TEST(FormatterTest, Units) {