mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-19 12:34:31 -04:00
Add proper catch2 support: - add catch2 as a submodule - add cmake function to add test easily - discover each test in test binary - remove copies of catch.hpp - do not try to process tests for rt1051 Do not test internals of utf8, only public interface (nasty bugs could occur otherwise). Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
|
|
#include <cstring>
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <unistd.h>
|
|
|
|
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include "common_data/Clipboard.hpp"
|
|
|
|
TEST_CASE("Clipboard")
|
|
{
|
|
SECTION("No data")
|
|
{
|
|
// It is guaranted to have no data only during 1st call to singleton getInstance()
|
|
REQUIRE(Clipboard::getInstance().gotData() == false);
|
|
REQUIRE(Clipboard::getInstance().paste() == "");
|
|
}
|
|
|
|
SECTION("Single copy")
|
|
{
|
|
const std::string test1 = "test1";
|
|
const std::string test2 = "test2";
|
|
Clipboard::getInstance().copy(test1);
|
|
REQUIRE(Clipboard::getInstance().gotData() == true);
|
|
REQUIRE(Clipboard::getInstance().paste() == test1);
|
|
REQUIRE(Clipboard::getInstance().gotData() == true);
|
|
}
|
|
|
|
SECTION("Double copy")
|
|
{
|
|
const std::string test1 = "test1";
|
|
const std::string test2 = "test2";
|
|
Clipboard::getInstance().copy(test1);
|
|
REQUIRE(Clipboard::getInstance().gotData() == true);
|
|
Clipboard::getInstance().copy(test2);
|
|
REQUIRE(Clipboard::getInstance().gotData() == true);
|
|
REQUIRE(Clipboard::getInstance().paste() == test2);
|
|
REQUIRE(Clipboard::getInstance().gotData() == true);
|
|
}
|
|
|
|
SECTION("Copy empty string")
|
|
{
|
|
const std::string test1 = "";
|
|
Clipboard::getInstance().copy(test1);
|
|
REQUIRE(Clipboard::getInstance().gotData() == true);
|
|
REQUIRE(Clipboard::getInstance().paste() == test1);
|
|
REQUIRE(Clipboard::getInstance().gotData() == true);
|
|
}
|
|
}
|