File indexing completed on 2024-04-21 04:39:54

0001 /* AtCore Unit Tests
0002  * SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003  * SPDX-FileCopyrightText: 2017, 2019 Chris Rizzitello <rizzitello@kde.org>
0004  * SPDX-FileCopyrightText: 2018 Lays Rodrigues <lays.rodrigues@kde.org>
0005  * SPDX-FileCopyrightText: 2018 Patrick José Pereira <patrickjp@kde.org>
0006  */
0007 
0008 #include <algorithm>
0009 
0010 #include <QtTest>
0011 
0012 #include "temperaturetests.h"
0013 
0014 void TemperatureTests::initTestCase()
0015 {
0016     temperature = new Temperature(this);
0017 }
0018 
0019 void TemperatureTests::cleanup()
0020 {
0021     temperature->resetData();
0022 }
0023 
0024 void TemperatureTests::testDecodeAprinter()
0025 {
0026     temperature->decodeTemp(QByteArray("ok B:49.06 /55 T:64.78 /215"));
0027     QVERIFY(temperature->extruderTemperature() == float(64.78));
0028     QVERIFY(temperature->extruderTargetTemperature() == 215);
0029     QVERIFY(temperature->bedTemperature() == float(49.06));
0030     QVERIFY(temperature->bedTargetTemperature() == 55);
0031 }
0032 
0033 void TemperatureTests::testDecodeMarlin()
0034 {
0035     temperature->decodeTemp(QByteArray("ok T:49.74 /60.00 B:36.23 /50.00 @:0 B@:0"));
0036     QVERIFY(temperature->extruderTemperature() == float(49.74));
0037     QVERIFY(temperature->extruderTargetTemperature() == 60);
0038     QVERIFY(temperature->bedTemperature() == float(36.23));
0039     QVERIFY(temperature->bedTargetTemperature() == 50);
0040 }
0041 
0042 void TemperatureTests::testDecodeMarlinCreality()
0043 {
0044     temperature->decodeTemp(QByteArray("ok T:48.8 /215.0 B:57.5 /70.0 T0:48.8 /0.0 @:0 B@:0"));
0045     QVERIFY(temperature->extruderTemperature() == float(48.8));
0046     QVERIFY(temperature->extruderTargetTemperature() == 215);
0047     QVERIFY(temperature->bedTemperature() == float(57.5));
0048     QVERIFY(temperature->bedTargetTemperature() == 70);
0049 }
0050 
0051 void TemperatureTests::testDecodeRepetier()
0052 {
0053     temperature->decodeTemp(QByteArray("T:25.47 /230 B:69.42 /80 B@:255 @:0"));
0054     QVERIFY(temperature->extruderTemperature() == float(25.47));
0055     QVERIFY(temperature->extruderTargetTemperature() == 230);
0056     QVERIFY(temperature->bedTemperature() == float(69.42));
0057     QVERIFY(temperature->bedTargetTemperature() == 80);
0058 }
0059 void TemperatureTests::testDecodeSmoothie()
0060 {
0061     temperature->decodeTemp(QByteArray("ok T:76.36 /220.0 @0 B:24.1 /60.0 @"));
0062     QVERIFY(temperature->extruderTemperature() == float(76.36));
0063     QVERIFY(temperature->extruderTargetTemperature() == 220);
0064     QVERIFY(temperature->bedTemperature() == float(24.1));
0065     QVERIFY(temperature->bedTargetTemperature() == 60);
0066 }
0067 void TemperatureTests::testDecodeSprinter()
0068 {
0069     temperature->decodeTemp(QByteArray("ok T:154 @:0 B:150"));
0070     QVERIFY(temperature->extruderTemperature() == 154);
0071     QVERIFY(temperature->bedTemperature() == 150);
0072 }
0073 
0074 void TemperatureTests::testDecodeTeacup()
0075 {
0076     temperature->decodeTemp(QByteArray("T:15.50/210.0 B:46.80/82.0"));
0077     QVERIFY(temperature->extruderTemperature() == float(15.50));
0078     QVERIFY(temperature->extruderTargetTemperature() == 210);
0079     QVERIFY(temperature->bedTemperature() == float(46.80));
0080     QVERIFY(temperature->bedTargetTemperature() == 82);
0081 }
0082 
0083 QTEST_MAIN(TemperatureTests)