Skip to content

Commit

Permalink
Test escapeString()
Browse files Browse the repository at this point in the history
  • Loading branch information
martinburchell committed Jul 14, 2023
1 parent c97dbce commit 2fe1e75
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/source/autodoc/tablet_qt/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,8 @@ tablet_qt
tests/auto/lib/margins/testmargins.cpp.rst
tests/auto/lib/soundfunc/soundfunc.pro.rst
tests/auto/lib/soundfunc/testsoundfunc.cpp.rst
tests/auto/lib/stringfunc/stringfunc.pro.rst
tests/auto/lib/stringfunc/teststringfunc.cpp.rst
tests/auto/questionnairelib/namevalueoptions/namevalueoptions.pro.rst
tests/auto/questionnairelib/namevalueoptions/testnamevalueoptions.cpp.rst
tests/auto/questionnairelib/questionnairelib.pro.rst
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. docs/source/autodoc/tablet_qt/tests/auto/lib/stringfunc/stringfunc.pro.rst
.. THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
.. Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
.
This file is part of CamCOPS.
.
CamCOPS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
CamCOPS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
tablet_qt/tests/auto/lib/stringfunc/stringfunc.pro
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../../../../../../../tablet_qt/tests/auto/lib/stringfunc/stringfunc.pro
:language: none
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. docs/source/autodoc/tablet_qt/tests/auto/lib/stringfunc/teststringfunc.cpp.rst
.. THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
.. Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
.
This file is part of CamCOPS.
.
CamCOPS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
CamCOPS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
tablet_qt/tests/auto/lib/stringfunc/teststringfunc.cpp
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../../../../../../../tablet_qt/tests/auto/lib/stringfunc/teststringfunc.cpp
:language: C++
1 change: 1 addition & 0 deletions tablet_qt/tests/auto/lib/lib.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ SUBDIRS += convert
SUBDIRS += filefunc
SUBDIRS += margins
SUBDIRS += soundfunc
SUBDIRS += stringfunc
56 changes: 56 additions & 0 deletions tablet_qt/tests/auto/lib/stringfunc/stringfunc.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
CONFIG += testcase
QT += network
QT += testlib
QT += widgets
QT -= gui

QT_BASE_DIR = $$(CAMCOPS_QT6_BASE_DIR) # value at time of qmake ("now")
isEmpty(QT_BASE_DIR) {
error("Environment variable CAMCOPS_QT6_BASE_DIR is undefined")
}

CAMCOPS_SRC = $$PWD/../../../..

MOC_DIR = moc
OBJECTS_DIR = obj
TARGET = bin/test_stringfunc

SOURCES += \
teststringfunc.cpp \
$$CAMCOPS_SRC/common/dpi.cpp \
$$CAMCOPS_SRC/common/textconst.cpp \
$$CAMCOPS_SRC/common/uiconst.cpp \
$$CAMCOPS_SRC/lib/convert.cpp \
$$CAMCOPS_SRC/lib/datetime.cpp \
$$CAMCOPS_SRC/lib/errorfunc.cpp \
$$CAMCOPS_SRC/lib/stringfunc.cpp \
$$CAMCOPS_SRC/lib/version.cpp \
$$CAMCOPS_SRC/maths/ccrandom.cpp \
$$CAMCOPS_SRC/maths/mathfunc.cpp \
$$CAMCOPS_SRC/whisker/whiskerapi.cpp \
$$CAMCOPS_SRC/whisker/whiskerconnectionstate.cpp \
$$CAMCOPS_SRC/whisker/whiskerconstants.cpp \
$$CAMCOPS_SRC/whisker/whiskerinboundmessage.cpp \
$$CAMCOPS_SRC/whisker/whiskeroutboundcommand.cpp

HEADERS += \
$$CAMCOPS_SRC/common/dpi.h \
$$CAMCOPS_SRC/common/textconst.h \
$$CAMCOPS_SRC/common/uiconst.h \
$$CAMCOPS_SRC/lib/convert.h \
$$CAMCOPS_SRC/lib/datetime.h \
$$CAMCOPS_SRC/lib/errorfunc.h \
$$CAMCOPS_SRC/lib/stringfunc.h \
$$CAMCOPS_SRC/lib/version.h \
$$CAMCOPS_SRC/maths/ccrandom.h \
$$CAMCOPS_SRC/maths/mathfunc.h \
$$CAMCOPS_SRC/whisker/whiskerapi.h \
$$CAMCOPS_SRC/whisker/whiskerconnectionstate.h \
$$CAMCOPS_SRC/whisker/whiskerconstants.h \
$$CAMCOPS_SRC/whisker/whiskerinboundmessage.h \
$$CAMCOPS_SRC/whisker/whiskeroutboundcommand.h

INCLUDEPATH += "$${QT_BASE_DIR}/eigen/eigen-3.4.0"
INCLUDEPATH += $$CAMCOPS_SRC

DEFINES += SRCDIR=\\\"$$PWD/\\\"
46 changes: 46 additions & 0 deletions tablet_qt/tests/auto/lib/stringfunc/teststringfunc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CamCOPS.
CamCOPS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CamCOPS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
*/

#include <QtTest/QtTest>

#include "lib/stringfunc.h"


class TestStringfunc: public QObject
{
Q_OBJECT

private slots:
void testEscapeStringReturnsQuotedEscapedString();
};


using namespace stringfunc;

void TestStringfunc::testEscapeStringReturnsQuotedEscapedString()
{
const QString value = QString(QByteArray("\x07\x20\x41\x42\x43"));

QCOMPARE(escapeString(value), QString("\"\\g ABC\""));
}

QTEST_MAIN(TestStringfunc)

#include "teststringfunc.moc"

0 comments on commit 2fe1e75

Please sign in to comment.