37#include <gtest/gtest.h>
50 std::vector<std::vector<int>>
data;
59 for (
long i = 0; i < r; ++i)
80 mat = std::make_unique<SimpleMatrix>(3, 3);
82 for (
long i = 0; i < 3; ++i)
83 for (
long j = 0; j < 3; ++j)
87 std::unique_ptr<SimpleMatrix>
mat;
95 return "R" + std::to_string(i);
103 return "C" + std::to_string(j);
111 return std::to_string(m(i, j));
117 std::ostringstream
out;
122 std::string result =
out.str();
125 EXPECT_TRUE(result.find(
"\\begin{tabular}") != std::string::npos);
126 EXPECT_TRUE(result.find(
"\\end{tabular}") != std::string::npos);
127 EXPECT_TRUE(result.find(
"\\hline") != std::string::npos);
132 std::ostringstream
out;
137 std::string result =
out.str();
139 EXPECT_TRUE(result.find(
"C0") != std::string::npos);
140 EXPECT_TRUE(result.find(
"C1") != std::string::npos);
141 EXPECT_TRUE(result.find(
"C2") != std::string::npos);
146 std::ostringstream
out;
151 std::string result =
out.str();
153 EXPECT_TRUE(result.find(
"R0") != std::string::npos);
154 EXPECT_TRUE(result.find(
"R1") != std::string::npos);
155 EXPECT_TRUE(result.find(
"R2") != std::string::npos);
160 std::ostringstream
out;
165 std::string result =
out.str();
168 for (
int i = 1; i <= 9; ++i)
169 EXPECT_TRUE(result.find(std::to_string(i)) != std::string::npos)
170 <<
"Value " << i <<
" not found in output";
175 std::ostringstream
out;
178 *mat, 3, 3,
out,
"PREFIX_START\n",
"SUFFIX_END\n");
180 std::string result =
out.str();
182 EXPECT_TRUE(result.find(
"PREFIX_START") != std::string::npos);
183 EXPECT_TRUE(result.find(
"SUFFIX_END") != std::string::npos);
186 EXPECT_EQ(result.find(
"PREFIX_START"), 0u);
196 std::ostringstream
out;
200 std::string result =
out.str();
202 EXPECT_TRUE(result.find(
"10") != std::string::npos);
203 EXPECT_TRUE(result.find(
"20") != std::string::npos);
204 EXPECT_TRUE(result.find(
"30") != std::string::npos);
214 std::ostringstream
out;
218 std::string result =
out.str();
220 EXPECT_TRUE(result.find(
"100") != std::string::npos);
221 EXPECT_TRUE(result.find(
"200") != std::string::npos);
222 EXPECT_TRUE(result.find(
"300") != std::string::npos);
227 std::ostringstream
out;
230 std::string result =
out.str();
233 EXPECT_TRUE(result.find(
"0") != std::string::npos);
234 EXPECT_TRUE(result.find(
"1") != std::string::npos);
235 EXPECT_TRUE(result.find(
"2") != std::string::npos);
240 std::ostringstream
out;
242 *mat, 3, 3,
out,
"",
"");
244 std::string result =
out.str();
252 std::ostringstream
out;
256 std::string result =
out.str();
260 for (
char c : result)
279 for (
long i = 0; i < 10; ++i)
280 for (
long j = 0; j < 10; ++j)
281 large(i, j) =
static_cast<int>(i * 10 + j);
283 std::ostringstream
out;
286 std::string result =
out.str();
288 EXPECT_TRUE(result.find(
"\\begin{tabular}") != std::string::npos);
289 EXPECT_TRUE(result.find(
"99") != std::string::npos);
295 for (
long i = 0; i < 2; ++i)
296 for (
long j = 0; j < 5; ++j)
297 rect(i, j) =
static_cast<int>(i * 5 + j);
299 std::ostringstream
out;
302 std::string result =
out.str();
307 while ((pos = result.find(
"p{1mm}", pos)) != std::string::npos)
320 std::ostringstream
out;
323 std::string result =
out.str();
325 EXPECT_TRUE(result.find(
"42") != std::string::npos);
326 EXPECT_TRUE(result.find(
"\\begin{tabular}") != std::string::npos);
337 std::ostringstream
out;
340 std::string result =
out.str();
342 EXPECT_TRUE(result.find(
"-5") != std::string::npos);
343 EXPECT_TRUE(result.find(
"-10") != std::string::npos);
344 EXPECT_TRUE(result.find(
"-100") != std::string::npos);
403 return "\\textbf{" + std::to_string(i) +
"}";
411 return "\\textit{" + std::to_string(j) +
"}";
420 if (val == std::numeric_limits<int>::max())
422 return std::to_string(val);
434 std::ostringstream
out;
438 std::string result =
out.str();
440 EXPECT_TRUE(result.find(
"\\textbf{0}") != std::string::npos);
441 EXPECT_TRUE(result.find(
"\\textbf{1}") != std::string::npos);
448 std::ostringstream
out;
452 std::string result =
out.str();
454 EXPECT_TRUE(result.find(
"\\textit{0}") != std::string::npos);
455 EXPECT_TRUE(result.find(
"\\textit{1}") != std::string::npos);
462 mat(0, 1) = std::numeric_limits<int>::max();
463 mat(1, 0) = std::numeric_limits<int>::max();
466 std::ostringstream
out;
470 std::string result =
out.str();
472 EXPECT_TRUE(result.find(
"\\infty") != std::string::npos);
473 EXPECT_TRUE(result.find(
"5") != std::string::npos);
482 ::testing::InitGoogleTest(&
argc,
argv);
std::unique_ptr< SimpleMatrix > mat
int & operator()(long i, long j)
int operator()(long i, long j) const
std::vector< std::vector< int > > data
SimpleMatrix(long r, long c)
Matrix to LaTeX table conversion utilities.
TEST_F(MatLatexTest, BasicOutput)
Main namespace for Aleph-w library functions.
void mat_to_latex_simple(Mat &mat, long n, long m, std::ostream &out, const std::string &prefix="", const std::string &suffix="")
Generate LaTeX table with default formatters.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
std::string operator()(SimpleMatrix &m, long i, long j) const