+ Unit test framework

+ README
+ LICENSE
+ CHANGELOG
This commit is contained in:
Johannes Theiner 2019-10-16 15:44:13 +02:00
parent 163ce56f71
commit afc6e47560
9 changed files with 116 additions and 14 deletions

4
.gitignore vendored
View File

@ -1,4 +0,0 @@
cmake-build-*/
build/
.idea/
.vs/

33
CHANGELOG.md Normal file
View File

@ -0,0 +1,33 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
- Continuous Integration
## [0.0.1] - 2019-10-24
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
## [0.0.0] - 2019-10-17
### Added
- README
- LICENCE
- CMake configuration

View File

@ -1,15 +1,35 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds are disabled.
Please create a subfolder called build and use `cmake ..` inside it.
NOTE: cmake will now create CMakeCache.txt and CMakeFiles/*.
You must delete them, or cmake will refuse to work.")
endif()
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "bin" "doc" "CMakeFiles" "lib" "include")
project(TextRenderer) project(TextRenderer)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
file(GLOB_RECURSE SOURCES src/*.cpp) file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS src/*.h) file(GLOB_RECURSE HEADERS src/*.h)
file(GLOB_RECURSE TESTS test/*.cpp)
include_directories(src) include_directories(src)
include_directories(test)
set(LIB_PATH "${CMAKE_SOURCE_DIR}/../library/build") set(LIB_PATH "${CMAKE_SOURCE_DIR}/../library")
include_directories(${LIB_PATH}/include) include_directories(${LIB_PATH}/include)
add_executable(TextRenderer ${SOURCES} ${HEADERS} src/Bitmap.cpp src/Bitmap.h) add_executable(TextRenderer ${SOURCES} ${HEADERS} main/main.cpp)
target_link_libraries(TextRenderer ${LIB_PATH}/lib/liblibrary.a) target_link_libraries(TextRenderer ${LIB_PATH}/lib/liblibrary.a)
enable_testing()
find_package(Catch2 REQUIRED)
add_executable(UnitTests ${SOURCES} ${HEADERS} ${TESTS})
target_link_libraries(UnitTests Catch2::Catch2)
include(CTest)
include(Catch)
catch_discover_tests(UnitTests)

29
LICENCE Normal file
View File

@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2019, Projektgruppe vKVM WS 2019
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# vKVM TextRenderer
## Installation
Use the installation script provided in the Scripts repository
to install the full package.
Installing a single component is currently not supported.

View File

@ -3,7 +3,7 @@
#include "add.h" #include "add.h"
#include "Bitmap.h" #include "Bitmap.h"
/* /**
* @author: Julian Hinxlage * @author: Julian Hinxlage
* @since: v0.0.0 * @since: v0.0.0
* @brief: An image is loaded and used as a font. * @brief: An image is loaded and used as a font.

View File

@ -3,7 +3,7 @@
#include <string> #include <string>
/* /**
* @author: Julian Hinxlage * @author: Julian Hinxlage
* @since: v0.0.0 * @since: v0.0.0
* @brief: Used to load a Bitmap from a file. * @brief: Used to load a Bitmap from a file.
@ -14,42 +14,42 @@ public:
~Bitmap(); ~Bitmap();
/* /**
* @author: Julian Hinxlage * @author: Julian Hinxlage
* @since: v0.0.0 * @since: v0.0.0
* @brief: Used to load a Bitmap from a file. * @brief: Used to load a Bitmap from a file.
*/ */
void load(const std::string &file); void load(const std::string &file);
/* /**
* @author: Julian Hinxlage * @author: Julian Hinxlage
* @since: v0.0.0 * @since: v0.0.0
* @return: the width of the image. * @return: the width of the image.
*/ */
int getWidth(); int getWidth();
/* /**
* @author: Julian Hinxlage * @author: Julian Hinxlage
* @since: v0.0.0 * @since: v0.0.0
* @return: the height of the image * @return: the height of the image
*/ */
int getHeight(); int getHeight();
/* /**
* @author: Julian Hinxlage * @author: Julian Hinxlage
* @since: v0.0.0 * @since: v0.0.0
* @return: the pixel data as an byte array * @return: the pixel data as an byte array
*/ */
char *getData(); char *getData();
/* /**
* @author: Julian Hinxlage * @author: Julian Hinxlage
* @since: v0.0.0 * @since: v0.0.0
* @return: the number of bits uses per pixel * @return: the number of bits uses per pixel
*/ */
int getBitsPerPixel(); int getBitsPerPixel();
/* /**
* @author: Julian Hinxlage * @author: Julian Hinxlage
* @since: v0.0.0 * @since: v0.0.0
* @return: the pixel value by coordinates, (0,0) is on the top left * @return: the pixel value by coordinates, (0,0) is on the top left

9
test/test_bitmap.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <catch2/catch.hpp>
#include <Bitmap.h>
TEST_CASE("default values") {
Bitmap bitmap = Bitmap();
REQUIRE(bitmap.getWidth() == 0);
REQUIRE(bitmap.getHeight() == 0);
REQUIRE(bitmap.getBitsPerPixel() == 0);
}

6
test/test_main.cpp Normal file
View File

@ -0,0 +1,6 @@
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
//Dont touch this file.
// add your own tests in this directory according to https://github.com/catchorg/Catch2/blob/master/docs/tutorial.md