File indexing completed on 2024-09-01 06:55:59
0001 /* 0002 File : MatrixFormulaTest.cpp 0003 Project : LabPlot 0004 Description : Tests for formula in matrix 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2022 Stefan Gerlach <stefan.gerlach@uni.kn> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #include "MatrixFormulaTest.h" 0012 #include "backend/lib/macros.h" 0013 #include "backend/matrix/Matrix.h" 0014 0015 #define INIT_MATRIX \ 0016 Matrix m(QStringLiteral("test matrix"), false); \ 0017 QStringList variableNames; \ 0018 variableNames << QStringLiteral("x") << QStringLiteral("y"); 0019 0020 //********************************************************** 0021 //********** Check different formulas ********************** 0022 //********************************************************** 0023 /*! 0024 formula "1" 0025 */ 0026 void MatrixFormulaTest::formula1() { 0027 INIT_MATRIX 0028 0029 m.setFormula(QStringLiteral("1")); 0030 // TODO: currently only via MatrixFunctionDialog 0031 // m.updateFormula(); 0032 0033 const int rows = 10; 0034 const int cols = 10; 0035 0036 QCOMPARE(m.columnCount(), cols); 0037 QCOMPARE(m.rowCount(), rows); 0038 0039 // values 0040 for (int i = 0; i < rows; i++) { 0041 for (int j = 0; j < cols; j++) { 0042 QCOMPARE(m.cell<double>(i, j), 0); 0043 } 0044 } 0045 } 0046 QTEST_MAIN(MatrixFormulaTest)