Commit 496f4893 authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Add a test for Character

This class is severely undertested
parent 1cd4dea4
......@@ -23,6 +23,12 @@ ecm_mark_nongui_executable(CharacterWidthTest)
add_test(NAME CharacterWidthTest COMMAND CharacterWidthTest)
target_link_libraries(CharacterWidthTest ${KONSOLE_TEST_LIBS})
add_executable(CharacterTest CharacterTest.cpp)
ecm_mark_as_test(CharacterTest)
ecm_mark_nongui_executable(CharacterTest)
add_test(NAME CharacterTest COMMAND CharacterTest)
target_link_libraries(CharacterTest ${KONSOLE_TEST_LIBS})
if ("$ENV{USER}" STREQUAL "jenkins")
message(STATUS "We are running in jenkins; skipping DBusTest...")
else()
......
#include "CharacterTest.h"
#include "Character.h"
#include <QTest>
#include <cstdint>
void Konsole::CharacterTest::testCanBeGrouped()
{
// Test for Capital Latin
for (uint32_t c = U'A'; c <= U'Z'; c++) {
Konsole::Character uppercase_latin_char(c);
const bool res = uppercase_latin_char.canBeGrouped(false, false);
QCOMPARE(res, true);
}
// Test for Non Capital Latin
for (uint32_t c = U'a'; c <= U'z'; c++) {
Konsole::Character lowercase_latin_char(c);
const bool res = lowercase_latin_char.canBeGrouped(false, false);
QCOMPARE(res, true);
}
// Test for Braille
for (uint32_t c = 0x2800; c <= 0x28ff; c++) {
Konsole::Character braille_char(c);
const bool res = braille_char.canBeGrouped(false, false);
QCOMPARE(res, false);
// TEST FOR REGRESSION - This was failing with different bidirectional modes.
Konsole::Character braille_char_bidi_enabled(c);
const bool res2 = braille_char_bidi_enabled.canBeGrouped(true, false);
QCOMPARE(res2, false);
}
}
QTEST_GUILESS_MAIN(Konsole::CharacterTest)
/*
SPDX-FileCopyrightText: 2019 Tomaz Canabrava <tomaz.canabrava@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
namespace Konsole
{
class CharacterTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testCanBeGrouped();
};
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment