Skip to content

Commit

Permalink
Added test for Expression class (#7951)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Sep 29, 2021
1 parent 5e2fb7f commit 51bb7b1
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 2 deletions.
39 changes: 39 additions & 0 deletions OMEdit/Testsuite/Expression/Expression.pro
@@ -0,0 +1,39 @@
#
# This file is part of OpenModelica.
#
# Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
# c/o Linköpings universitet, Department of Computer and Information Science,
# SE-58183 Linköping, Sweden.
#
# All rights reserved.
#
# THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
# THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
# ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
# OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
#
# The OpenModelica software and the Open Source Modelica
# Consortium (OSMC) Public License (OSMC-PL) are obtained
# from OSMC, either from the above address,
# from the URLs: http://www.ida.liu.se/projects/OpenModelica or
# http://www.openmodelica.org, and in the OpenModelica distribution.
# GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
#
# This program is distributed WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
# IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
#
# See the full OSMC Public License conditions for more details.
#
#/

include(../Common/Testsuite.pri)

TARGET = Expression

SOURCES += ../Common/Util.cpp \
ExpressionTest.cpp

HEADERS += ../Common/Util.h \
ExpressionTest.h
62 changes: 62 additions & 0 deletions OMEdit/Testsuite/Expression/ExpressionTest.cpp
@@ -0,0 +1,62 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
/*
* @author Adeel Asghar <adeel.asghar@liu.se>
*/

#include "ExpressionTest.h"
#include "Util.h"
#include "OMEditApplication.h"
#include "MainWindow.h"
#include "FlatModelica/Expression.h"

#define GC_THREADS
extern "C" {
#include "meta/meta_modelica.h"
}

OMEDITTEST_MAIN(ExpressionTest)

void ExpressionTest::dynamicSelectString()
{
QString str = "DynamicSelect(\"0.0\", String(showNumber, significantDigits, 0, true))";
try {
FlatModelica::Expression::parse(str);
} catch (const std::exception &e) {
qDebug() << e.what();
QFAIL(QString("Failed to parse:").arg(str).toStdString().c_str());
}
}

void ExpressionTest::cleanupTestCase()
{
MainWindow::instance()->close();
}
53 changes: 53 additions & 0 deletions OMEdit/Testsuite/Expression/ExpressionTest.h
@@ -0,0 +1,53 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
/*
* @author Adeel Asghar <adeel.asghar@liu.se>
*/

#ifndef DIAGRAM_H
#define DIAGRAM_H

#include <QObject>

/*!
* \brief The ExpressionTest class
* Tests the Expression class.
*/
class ExpressionTest: public QObject
{
Q_OBJECT

private slots:
void dynamicSelectString();
void cleanupTestCase();
};

#endif // DIAGRAM_H
2 changes: 1 addition & 1 deletion OMEdit/Testsuite/RunOMEditTestsuite.sh
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

testcases=( "BrowseMSL" "Diagram" "Transformation" "Homotopy" )
testcases=( "BrowseMSL" "Diagram" "Transformation" "Homotopy" "Expression" )
OMEditTestResults="$PWD/OMEditTestResult"

for i in "${testcases[@]}"
Expand Down
3 changes: 2 additions & 1 deletion OMEdit/Testsuite/Testsuite.pro
Expand Up @@ -33,5 +33,6 @@ TEMPLATE = subdirs
SUBDIRS = BrowseMSL \
Diagram \
Transformation \
Homotopy
Homotopy \
Expression

0 comments on commit 51bb7b1

Please sign in to comment.