Added cmake build config
This commit is contained in:
parent
1275c47676
commit
3465d60d81
8
.gitignore
vendored
8
.gitignore
vendored
@ -360,4 +360,10 @@ MigrationBackup/
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
FodyWeavers.xsd
|
||||
|
||||
a.out
|
||||
|
||||
.vscode/
|
||||
|
||||
build/
|
10
CMakeLists.txt
Normal file
10
CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(QRCodeLibrary)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_subdirectory(Demo)
|
||||
add_subdirectory(QRCodeLibrary)
|
||||
add_subdirectory(tests)
|
13
Demo/CMakeLists.txt
Normal file
13
Demo/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
set(Demo_SRCS
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(QRCodeLibraryDemo
|
||||
${Demo_SRCS}
|
||||
)
|
||||
|
||||
target_link_libraries(QRCodeLibraryDemo
|
||||
QRCodeLibrary
|
||||
)
|
||||
|
||||
install(TARGETS QRCodeLibraryDemo DESTINATION bin)
|
14
QRCodeLibrary/CMakeLists.txt
Normal file
14
QRCodeLibrary/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
file(GLOB_RECURSE SOURCES LIST_DIRECTORIES true *.hpp *.cpp)
|
||||
|
||||
set(QRCodeLibrary_SRCS ${SOURCES})
|
||||
|
||||
# Declare the library
|
||||
add_library(QRCodeLibrary STATIC
|
||||
${QRCodeLibrary_SRCS}
|
||||
)
|
||||
|
||||
# Specify here the include directories exported
|
||||
# by this library
|
||||
target_include_directories(QRCodeLibrary PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
49
tests/CMakeLists.txt
Normal file
49
tests/CMakeLists.txt
Normal file
@ -0,0 +1,49 @@
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
# Enable ExternalProject CMake module
|
||||
include(ExternalProject)
|
||||
|
||||
# Download and install GoogleTest
|
||||
ExternalProject_Add(
|
||||
gtest
|
||||
URL https://github.com/google/googletest/archive/refs/heads/main.zip
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
|
||||
# Disable install step
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(gtest source_dir binary_dir)
|
||||
|
||||
add_library(libgtest IMPORTED STATIC GLOBAL)
|
||||
add_dependencies(libgtest gtest)
|
||||
|
||||
set_target_properties(libgtest PROPERTIES
|
||||
"IMPORTED_LOCATION" "${binary_dir}/lib/libgtest.a"
|
||||
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
|
||||
)
|
||||
|
||||
add_library(libgmock IMPORTED STATIC GLOBAL)
|
||||
add_dependencies(libgmock gtest)
|
||||
|
||||
set_target_properties(libgmock PROPERTIES
|
||||
"IMPORTED_LOCATION" "${binary_dir}/lib/libgmock.a"
|
||||
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
|
||||
)
|
||||
|
||||
# I couldn't make it work with INTERFACE_INCLUDE_DIRECTORIES
|
||||
include_directories("${source_dir}/googletest/include"
|
||||
"${source_dir}/googlemock/include")
|
||||
|
||||
|
||||
file(GLOB SRCS *.cpp)
|
||||
|
||||
ADD_EXECUTABLE(testQRCode ${SRCS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(testQRCode
|
||||
QRCodeLibrary
|
||||
libgtest
|
||||
libgmock
|
||||
)
|
||||
|
||||
add_test(NAME testQRCode
|
||||
COMMAND testQRCode)
|
@ -6,9 +6,13 @@
|
||||
#include "../QRCodeLibrary/Method.hpp"
|
||||
|
||||
TEST(MethodTests, DetermitesStringMethod) {
|
||||
EXPECT_EQ(Method::determite_method(std::string("123")), QRCodeMethod::Numeric);
|
||||
EXPECT_EQ(Method::determite_method(std::string("ABC")), QRCodeMethod::Alphabetic);
|
||||
EXPECT_EQ(Method::determite_method(std::string("ghfjghfj gfjhgd")), QRCodeMethod::Byte);
|
||||
string a1("123");
|
||||
string a2("ABC");
|
||||
string a3("ghfjghfj gfjhgd");
|
||||
|
||||
EXPECT_EQ(Method::determite_method(a1), QRCodeMethod::Numeric);
|
||||
EXPECT_EQ(Method::determite_method(a2), QRCodeMethod::Alphabetic);
|
||||
EXPECT_EQ(Method::determite_method(a3), QRCodeMethod::Byte);
|
||||
}
|
||||
|
||||
TEST(MethodTests, ChecksNumber) {
|
||||
|
@ -11,7 +11,8 @@ public:
|
||||
QRCodeConstructorMock(Parameters ...params) {};
|
||||
};
|
||||
TEST(QRCodeTests, ConstructsClass) {
|
||||
QRCode qr(std::string("TEST"));
|
||||
string inp("TEST");
|
||||
QRCode qr(inp);
|
||||
|
||||
EXPECT_EQ(qr.input, "TEST");
|
||||
EXPECT_EQ(qr.corr_lvl, CorrectionLevel::M);
|
||||
@ -33,7 +34,9 @@ TEST(QRCodeTests, CreatesQRCode) {
|
||||
//QRCode qr(std::string("ALICE WAS BEGINNING TO GET VERY TIRED OF SITTING BY HER SISTER ON THE BANK AND OF HAVING NOTHING TO DO: ONCE OR TWICE SHE HAD PEEPED INTO THE BOOK HER SISTER WAS READING BUT IT HAD NO PICTURES OR CONVERSATIONS IN IT AND WHAT IS THE USE OF A BOOK THOUGHT ALICE WITHOUT PICTURES OR CONVERSATIONS. SO SHE WAS CONSIDERING IN HER OWN MIND AS WELL AS SHE COULD FOR THE HOT DAY MADE HER FEEL VERY SLEEPY AND STUPID. WHETHER THE PLEASURE OF MAKING A DAISY-CHAIN WOULD BE WORTH THE TROUBLE OF GETTING UP AND PICKING THE DAISIES WHEN SUDDENLY A WHITE RABBIT WITH PINK EYES RAN CLOSE BY HER. THERE WAS NOTHING SO VERY REMARKABLE IN THAT NOR DID ALICE THINK IT SO VERY MUCH OUT OF THE WAY TO HEAR THE RABBIT SAY TO ITSELF OH DEAR. OH DEAR. I SHALL BE LATE. WHEN SHE THOUGHT IT OVER AFTERWARDS IT OCCURRED TO HER THAT SHE OUGHT TO HAVE WONDERED AT THIS BUT AT THE TIME IT ALL SEEMED QUITE NATURAL. BUT WHEN THE RABBIT ACTUALLY TOOK A WATCH OUT OF ITS WAISTCOAT-POCKET AND LOOKED AT IT AND THEN HURRIED ON ALICE STARTED TO HER FEET FOR IT FLASHED ACROSS HER MIND THAT SHE HAD NEVER BEFORE SEEN A RABBIT WITH EITHER A WAISTCOAT-POCKET OR A WATCH TO TAKE OUT OF IT AND BURNING WITH CURIOSITY SHE RAN ACROSS THE FIELD AFTER IT AND FORTUNATELY WAS JUST IN TIME TO SEE IT POP DOWN A LARGE RABBIT-HOLE UNDER THE HEDGE. IN ANOTHER MOMENT DOWN WENT ALICE AFTER IT NEVER ONCE CONSIDERING HOW IN THE WORLD SHE WAS TO GET OUT AGAIN. THE RABBIT-HOLE WENT STRAIGHT ON LIKE A TUNNEL FOR SOME WAY AND THEN DIPPED SUDDENLY DOWN SO SUDDENLY THAT ALICE HAD NOT A MOMENT TO THINK ABOUT STOPPING HERSELF BEFORE SHE FOUND HERSELF FALLING DOWN A VERY DEEP WELL. EITHER THE WELL WAS VERY DEEP OR SHE FELL VERY SLOWLY FOR SHE HAD PLENTY OF TIME AS SHE WENT DOWN TO LOOK ABOUT HER AND TO WONDER WHAT WAS GOING TO HAPPEN NEXT. FIRST SHE TRIED TO LOOK DOWN AND MAKE OUT WHAT SHE WAS COMING TO BUT IT WAS TOO DARK TO SEE ANYTHING THEN SHE LOOKED AT THE SIDES OF THE WELL AND NOTICED THAT THEY WERE FILLED WITH CUPBOARDS AND BOOK-SHELVES HERE AND THERE SHE SAW MAPS AND PICTURES HUNG UPON PEGS. SHE TOOK DOWN A JAR FROM ONE OF THE SHELVES AS SHE PASSED IT WAS LABELLED ORANGE MARMALADE BUT TO HER GREAT DISAPPOINTMENT IT WAS EMPTY: SHE DID NOT LIKE TO DROP THE JAR FOR FEAR OF KILLING SOMEBODY UNDERNEATH SO MANAGED TO PUT IT INTO ONE OF THE CUPBOARDS AS SHE FELL PAST IT. WELL. THOUGHT ALICE TO HERSELF AFTER SUCH A FALL AS THIS I SHALL THINK NOTHING OF TUMBLING DOWN STAIRS. HOW BRAVE THEYLL ALL THINK ME AT HOME. WHY I WOULDNT SAY ANYTHING ABOUT IT EVEN IF I FELL OFF THE TOP OF THE HOUSE. WHICH WAS VERY LIKELY TRUE.. DOWN DOWN DOWN. WOULD THE FALL NEVER COME TO AN END. I WONDER HOW MANY MILES IVE FALLEN BY THIS TIME. SHE SAID ALOUD. I MUST BE GETTING SOMEWHERE NEAR THE CENTRE OF THE EARTH. LET ME SEE: THAT WOULD BE FOUR THOUSAND MILES DOWN I THINK- FOR YOU SEE ALICE HAD LEARNT SEVERAL THINGS OF THIS SORT IN HER LESSONS IN THE SCHOOLROOM AND THOUGH THIS WAS NOT A VERY GOOD OPPORTUNITY FOR SHOWING OFF HER KNOWLEDGE AS THERE WAS NO ONE TO LISTEN TO HER STILL IT WAS GOOD PRACTICE TO SAY IT OVER. -YES THATS ABOUT THE RIGHT DISTANCE-BUT THEN I WONDER WHAT LATITUDE OR LONGITUDE IVE GOT TO. ALICE HAD NO IDEA WHAT LATITUDE WAS OR LONGITUDE EITHER BUT THOUGHT THEY WERE NICE GRAND WORDS TO SAY.. PRESENTLY SHE BEGAN AGAIN. I WONDER IF I SHALL FALL RIGHT THROUGH THE EARTH. HOW FUNNY ITLL SEEM TO COME OUT AMONG THE PEOPLE THAT WALK WITH THEIR HEADS DOWNWARD. THE ANTIPATHIES I THINK- SHE WAS RATHER GLAD THERE WAS NO ONE LISTENING THIS TIME AS IT DIDNT SOUND AT ALL THE RIGHT WORD. -BUT I SHALL HAVE TO ASK THEM WHAT THE NAME OF THE COUNTRY IS YOU KNOW. PLEASE MAAM IS THIS NEW ZEALAND OR AUSTRALIA. AND SHE TRIED TO CURTSEY AS SHE SPOKE-FANCY CURTSEYING AS YOURE FALLING THROUGH THE AIR. DO YOU THINK YOU COULD MANAGE IT.. AND WHAT AN IGNORANT LITTLE GIRL SHELL THINK ME FOR ASKING. NO ITLL NEVER DO TO ASK: PERHAPS I SHALL SEE IT WRITTEN UP SOMEWHERE. DOWN DOWN DOWN. THERE WAS NOTHING ELSE TO DO SO ALICE SOON BEGAN TALKING AGAIN. DINAHLL MISS ME VERY MUCH TO-NIGHT I SHOULD THINK. DINAH WAS THE CAT.. I HOPE THEYLL REMEMBER HER SAUCER OF MILK AT TEA-TIME. DINAH MY DEAR. I WISH YOU WERE DOWN HERE WITH ME. THERE ARE NO MICE IN THE AIR IM AFRAID BUT YOU MIGHT CATCH A BAT AND THATS VERY LIKE A MOUSE YOU KNOW. BUT DO CATS EAT BATS I WONDER. AND HERE ALICE BEGAN TO GET RATHER SLEEPY AND WENT ON SAYING TO HERSELF IN A DREAMY SORT OF WAY DO CATS EAT BATS. DO CATS EAT BATS. AND SOMETIMES DO BATS EAT CATS. FOR YOU SEE AS SHE COULDNT ANSWER EITHER QUESTION IT DIDNT MUCH MATTER WHICH WAY SHE PUT IT. SHE FELT THAT SHE WAS DOZING OFF AND HAD JUST BEGUN TO DREAM THAT SHE WAS WALKING HAND IN HAND WITH DINAH AND SAYING TO HER VERY EARNESTLY NOW DINAH TELL ME THE TRUTH: DID YOU EVER EAT A BAT. WHEN SUDDENLY THUMP. THUMP. DOWN SHE CAME UPON A HEAP OF STICKS AND DRY LEAVES AND THE FALL WAS OVER."
|
||||
//).substr(0, 4296), CorrectionLevel::L);
|
||||
|
||||
QRCode qr(std::string(u8"Здравствуйте, я - QR-код, сгенерированный при помощи библиотеки QRCodeLibrary!"));
|
||||
string input(u8"Здравствуйте, я - QR-код, сгенерированный при помощи библиотеки QRCodeLibrary!");
|
||||
|
||||
QRCode qr(input);
|
||||
|
||||
EXPECT_EQ(qr.to_string(), "1111111000000000111011111011101110111100101111111\n1000001010110100000100010001000100010111101000001\n1011101000110110000110011101101110110101101011101\n1011101000000001001000110010111011111001001011101\n1011101011001100001011111110110011001000001011101\n1000001000011100110000100011100110010010001000001\n1111111010101010101010101010101010101010101111111\n0000000001001100101101100010101011010001000000000\n1010101000011111111001111110000000100110000010010\n0100100111010011010101000101001100100010000001001\n0110011111011011101010101000111011101110001110100\n1111110111010011101111100011010101101011010010110\n1101101110011100001011010110001000100011001001101\n0000000010001100100010111010011001010011101101000\n0000001100000100000000001110110010001110111010000\n0001010111110010001010110101001100110101010100010\n0000101101000100100100100011000100010111011000101\n1000100110101101101111000111101110111001101000000\n0110101010010101110010001101001100110100111011011\n1000010011011011101101000010110011000101001100100\n1000011000000001011100011000001001110111010001101\n1000010110101001100111010011011101100111101000010\n0101111110101001111010111110110010100010111110100\n0010100010001100100101100010010001000101100011000\n0010101010011001000111101011001100110010101010001\n0001100011101010100011100011011101100111100011000\n0111111110001110000001111110110011011101111110110\n1100000011010010110111110100010001000100100101111\n0000011101001011101110001011011100110010110001010\n1101010111010010001100101101001000111110010001000\n1111101010111111000110000010111001101100011011010\n1101100100011110010101101110010001010101111000010\n0000011010101010111110101010111011101001101110001\n0100010011110100100011111100010001000000110011000\n1011111100001000011000111000111011101101000010111\n0010010011010010000110110010000001010101101101110\n0000011101011110010110011101011101000111001111001\n0111110110101010101010101110110000100010010010100\n0100011111100001111010011100000011101110000010110\n0111000000000001111100101000110101101011101101001\n1110001010101100010100111110000000100111111110010\n0000000011110111100111100011001000110011100011101\n1111111001001101101011101010111011101110101010100\n1000001001000100110101100011110011010011100011010\n1011101011010000110010111110101000100000111110001\n1011101001100101111011111101011101100011110000110\n1011101011110010011000101111010011001111101101000\n1000001000100101011011000101001100111110011100010\n1111111011110000101100010111000100001110010110011");
|
||||
}
|
||||
|
8
tests/main_tests.cpp
Normal file
8
tests/main_tests.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
return ret;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user