File: MatrixFormulaTest.cpp

package info (click to toggle)
labplot 2.12.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,528 kB
  • sloc: cpp: 241,047; ansic: 6,324; python: 915; xml: 400; yacc: 237; sh: 221; awk: 35; makefile: 11
file content (46 lines) | stat: -rw-r--r-- 1,593 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
	File                 : MatrixFormulaTest.cpp
	Project              : LabPlot
	Description          : Tests for formula in matrix
	--------------------------------------------------------------------
	SPDX-FileCopyrightText: 2022 Stefan Gerlach <stefan.gerlach@uni.kn>

	SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "MatrixFormulaTest.h"
#include "backend/lib/macros.h"
#include "backend/matrix/Matrix.h"

#define INIT_MATRIX                                                                                                                                            \
	Matrix m(QStringLiteral("test matrix"), false);                                                                                                            \
	QStringList variableNames;                                                                                                                                 \
	variableNames << QStringLiteral("x") << QStringLiteral("y");

//**********************************************************
//********** Check different formulas **********************
//**********************************************************
/*!
   formula "1"
*/
void MatrixFormulaTest::formula1() {
	INIT_MATRIX

	m.setFormula(QStringLiteral("1"));
	// TODO: currently only via MatrixFunctionDialog
	// m.updateFormula();

	const int rows = 10;
	const int cols = 10;

	QCOMPARE(m.columnCount(), cols);
	QCOMPARE(m.rowCount(), rows);

	// values
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols; j++) {
			QCOMPARE(m.cell<double>(i, j), 0);
		}
	}
}
QTEST_MAIN(MatrixFormulaTest)