Pickler MVP is complete. Testing For Pickler is done. changed gitignore
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,7 +3,7 @@ CMakeLists.txt.user
|
|||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
CMakeScripts
|
CMakeScripts
|
||||||
Testing
|
#Testing
|
||||||
Makefile
|
Makefile
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
install_manifest.txt
|
install_manifest.txt
|
||||||
@@ -11,4 +11,6 @@ compile_commands.json
|
|||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
_deps
|
_deps
|
||||||
build/
|
build/
|
||||||
|
bin/
|
||||||
|
.cache/
|
||||||
.ccls-cache/
|
.ccls-cache/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.20.0)
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
project(Pickler VERSION 0.1)
|
project(PickleLib VERSION 0.1)
|
||||||
# CPP
|
# CPP
|
||||||
set( CMAKE_CXX_STANDARD 11)
|
set( CMAKE_CXX_STANDARD 11)
|
||||||
set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@@ -8,11 +8,18 @@ set( CMAKE_C_STANDARD 11)
|
|||||||
set( CMAKE_C_STANDARD_REQUIRED ON)
|
set( CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||||
|
|
||||||
set( CMAKE_COLOR_MAKEFILE ON)
|
set( CMAKE_COLOR_MAKEFILE ON)
|
||||||
set( CMAKE_COLOR_DIAGNOSTICS ON)
|
set( CMAKE_COLOR_DIAGNOSTICS ON)
|
||||||
|
|
||||||
set( CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set( CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
|
add_subdirectory(testing)
|
||||||
|
|
||||||
|
add_test(testing "${CMAKE_SOURCE_DIR}/bin/Debug/testing.exe")
|
||||||
|
|||||||
@@ -1,22 +1,74 @@
|
|||||||
#ifndef Pickler_H
|
#ifndef Pickler_H
|
||||||
#define Pickler_H
|
#define Pickler_H
|
||||||
#define PICKLER_CPP
|
|
||||||
|
|
||||||
struct pickle_obj{
|
struct pickle{
|
||||||
|
const char* name;
|
||||||
const char* message;
|
const char* message;
|
||||||
bool passed;
|
bool passed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef PICKLER_CPP
|
|
||||||
struct pickle_jar {
|
struct pickle_jar {
|
||||||
struct pickle_obj functions[10];
|
const char* name;
|
||||||
|
pickle* functions;
|
||||||
int functionCount;
|
int functionCount;
|
||||||
bool passed;
|
bool passed;
|
||||||
} ;
|
} ;
|
||||||
#endif
|
///
|
||||||
|
struct pickle_shelf {
|
||||||
|
struct pickle_jar* pickle_jars;
|
||||||
|
int pickle_jarCount = 0;
|
||||||
|
bool passed;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pickle_jar __pickle_add_jar(pickle_jar*, pickle, const char*);
|
||||||
|
struct pickle_shelf __pickle_jar_add_to_shelf(pickle_shelf*, pickle_jar);
|
||||||
|
int __pickle_shelf_run(pickle_shelf*);
|
||||||
|
|
||||||
|
|
||||||
#define PICKLE(x) struct pickle_obj x = [](struct pickle_jar&)
|
/// -----Operation functions-----
|
||||||
#define ADDPICKLE(x)
|
/// These operation functions alow quick
|
||||||
#define ADDJARTOSHLEF(x)
|
/// and easy comparesons.
|
||||||
|
/// So that the user can make tests fast.
|
||||||
|
/// Tests should be easy and to create and
|
||||||
|
/// simpile to create. More functions will
|
||||||
|
/// be on the way but right now we have the
|
||||||
|
/// following.
|
||||||
|
///
|
||||||
|
/// - DIFFERENT(value1, value2): this allows the
|
||||||
|
/// user to check if the value is differrent in
|
||||||
|
/// any way. (value1 != value2)
|
||||||
|
///
|
||||||
|
/// - SAME(value1, value2): this allows the user
|
||||||
|
/// to check if both values are the same.
|
||||||
|
/// (value1 == value2)
|
||||||
|
///
|
||||||
|
/// - ASSERT(message, value): allows for a custome
|
||||||
|
/// message to be displayed when testing. The value
|
||||||
|
/// is/needs to be a boolean.
|
||||||
|
|
||||||
|
#define DIFFERENT(value1, value2) (value1 != value2)
|
||||||
|
#define SAME(value1, value2) (value1 == value2)
|
||||||
|
#define ASSERT(message, value) return {"name",message, value }
|
||||||
|
|
||||||
|
/// ------Using Pickle------
|
||||||
|
/// When using pickle there are some
|
||||||
|
/// helper deffinitions to create your
|
||||||
|
/// testing envirment.
|
||||||
|
/// - First, Use _INSTALLSHELF_ to
|
||||||
|
/// install the pickle shelf.
|
||||||
|
/// - Second, we need to create pickle
|
||||||
|
/// jars so that we can put pickles in
|
||||||
|
/// those jars. To create a pickle jar
|
||||||
|
/// run _CREATEJAR_ to create a pickle
|
||||||
|
/// jar.
|
||||||
|
/// -Third, We can now start canning!
|
||||||
|
/// First we need to create Pickls.
|
||||||
|
/// To create a pickle we need to run
|
||||||
|
/// _PICKLE_ pickle takes a name.
|
||||||
|
///
|
||||||
|
#define INSTALLSHELF struct pickle_shelf __pickle_shelf__ = { 0, 0 };
|
||||||
|
#define CREATEJAR(jar_name) struct pickle_jar jar_name = {#jar_name, 0, 0, true};
|
||||||
|
#define PICKLE(name) struct pickle name = []() -> pickle
|
||||||
|
#define ADDPICKLE(jar,pickle) __pickle_add_jar(&jar, pickle, #pickle)
|
||||||
|
#define PUTJARONSHLEF(jar) __pickle_jar_add_to_shelf(&__pickle_shelf__,jar);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
set( CMAKE_STATIC_LIBRARY_PREFIX "")
|
set( CMAKE_STATIC_LIBRARY_PREFIX "")
|
||||||
set( CMAKE_STATIC_LIBRARY_SUFFIX "Lib")
|
#set( CMAKE_STATIC_LIBRARY_SUFFIX "Lib")
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
Pickler.cpp
|
Pickler.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(BEFORE "../includes/")
|
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
|
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
|
||||||
|
target_include_directories(${PROJECT_NAME} BEFORE PUBLIC "../includes/")
|
||||||
|
|||||||
@@ -1,2 +1,96 @@
|
|||||||
|
#include <iostream>
|
||||||
#include "Pickler.h"
|
#include "Pickler.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct pickle_jar __pickle_add_jar(pickle_jar* jar, pickle p, const char* pname) {
|
||||||
|
auto tmp = new pickle[jar->functionCount + 1];
|
||||||
|
for (int i = 0; i < jar->functionCount; i++) {
|
||||||
|
tmp[i] = jar->functions[i];
|
||||||
|
}
|
||||||
|
p.name = pname;
|
||||||
|
tmp[jar->functionCount] = p;
|
||||||
|
jar->functions = tmp;
|
||||||
|
jar->functionCount++;
|
||||||
|
return *jar;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct pickle_shelf __pickle_jar_add_to_shelf(pickle_shelf* shelf, pickle_jar jar) {
|
||||||
|
struct pickle_jar* tmps = new pickle_jar[shelf->pickle_jarCount + 1];
|
||||||
|
|
||||||
|
for(int i = 0; i < shelf->pickle_jarCount; i++) {
|
||||||
|
tmps[i] = shelf->pickle_jars[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tmps[shelf->pickle_jarCount] = jar;
|
||||||
|
|
||||||
|
shelf->pickle_jars = tmps;
|
||||||
|
shelf->pickle_jarCount++;
|
||||||
|
return *shelf;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void printoutShelf(pickle_shelf shelf) {
|
||||||
|
std::cout << "\033[1;92mPICKLER\033[1;39;49m There are \033[1;92m-[" << shelf.pickle_jarCount << "]-\033[1;39;49m Pickle Jars on the shelf\n";
|
||||||
|
}
|
||||||
|
void printoutShelfEnd(pickle_shelf shelf) {
|
||||||
|
std::cout << "[====Pickle Shelf====]\n";
|
||||||
|
if(shelf.passed) {
|
||||||
|
std::cout << "\033[1;92m[==Pickle Shelf Good=]\033[1;39;49m\n";
|
||||||
|
}else {
|
||||||
|
std::cout << "\033[1;31m[==Pickle Shelf Fell=]\033[1;39;49m\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void printoutJar(pickle_jar jar) {
|
||||||
|
|
||||||
|
std::cout << "There are \033[1;92m-["<< jar.functionCount <<"]- Pickles \033[1;39;49min \033[1;94;49m"<< jar.name <<"\033[1;39;49m Pickle Jar\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void printoutJarEnd(pickle_jar jar) {
|
||||||
|
std::cout << "[=====Pickle Jar=====]\n";
|
||||||
|
if(jar.passed) {
|
||||||
|
std::cout << "\033[1;92m[===Pickles In Jar===]\033[1;39;49m\n";
|
||||||
|
} else {
|
||||||
|
std::cout << "\033[1;31m[==Pickle Jar Broke==]\033[1;39;49m Broken Jar at \033[1;33m" << jar.name << "\033[1;39;49m\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void printoutPickle(pickle p) {
|
||||||
|
std::cout << "[======Pickling======] \033[1;92m" << p.name << "\033[1;39;49m Running \n";
|
||||||
|
if(p.passed) {
|
||||||
|
std::cout << "\033[1;92m[=======Pickled======]\n";
|
||||||
|
}else {
|
||||||
|
std::cout << "\033[1;31m[==Droped the Pickle=]" << p.message<<"\n";
|
||||||
|
}
|
||||||
|
std::cout << "[========DONE========]\033[1;39;49m\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int __pickle_shelf_run(pickle_shelf * shelf) {
|
||||||
|
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
printoutShelf(*shelf);
|
||||||
|
shelf->passed = true;
|
||||||
|
|
||||||
|
for(int i = 0; i < shelf->pickle_jarCount; i++) {
|
||||||
|
|
||||||
|
printoutJar(shelf->pickle_jars[i]);
|
||||||
|
|
||||||
|
shelf->pickle_jars[i].passed = true;
|
||||||
|
|
||||||
|
for(int j = 0; j < shelf->pickle_jars[i].functionCount; j++) {
|
||||||
|
|
||||||
|
printoutPickle(shelf->pickle_jars[i].functions[j]);
|
||||||
|
|
||||||
|
if(!shelf->pickle_jars[i].functions[j].passed) {
|
||||||
|
shelf->pickle_jars[i].passed = false;
|
||||||
|
shelf->passed = false;
|
||||||
|
status--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printoutJarEnd(shelf->pickle_jars[i]);
|
||||||
|
}
|
||||||
|
printoutShelfEnd(*shelf);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|||||||
3
testing/CMakeLists.txt
Normal file
3
testing/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
project(testing)
|
||||||
|
add_executable(testing source.cpp)
|
||||||
|
target_link_libraries(testing PickleLib)
|
||||||
42
testing/source.cpp
Normal file
42
testing/source.cpp
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#include "../includes/Pickler.h"
|
||||||
|
void testing() {
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
|
pickle_shelf __pickle_shelf__ = pickle_shelf();
|
||||||
|
|
||||||
|
CREATEJAR(Pickle_Logic_Tests);
|
||||||
|
CREATEJAR(Pickle_Deffinition_Test);
|
||||||
|
PICKLE(Add_Pickle_Test){
|
||||||
|
CREATEJAR(PickleAddTest);
|
||||||
|
struct pickle p = {"Pickle_Test","testing", true};
|
||||||
|
ADDPICKLE(PickleAddTest,p);
|
||||||
|
struct pickle_jar test_jar = { "PickleAddTest", &p, 1, true};
|
||||||
|
if(DIFFERENT(PickleAddTest.passed ,test_jar.passed)) {
|
||||||
|
ASSERT("PickleAddTest.passed and test_jar.passed different", false);
|
||||||
|
}
|
||||||
|
if(DIFFERENT(test_jar.name, PickleAddTest.name)) {
|
||||||
|
ASSERT("Name Not the Same",false);
|
||||||
|
}
|
||||||
|
if(DIFFERENT(test_jar.functionCount, PickleAddTest.functionCount)) {
|
||||||
|
ASSERT("functionCount not the same", false);
|
||||||
|
}
|
||||||
|
ASSERT("",true);
|
||||||
|
}();
|
||||||
|
PICKLE(Test_SAME){
|
||||||
|
ASSERT("This test should succsead", SAME(2,2));
|
||||||
|
}();
|
||||||
|
PICKLE(Test_DIFFERENT){
|
||||||
|
ASSERT("This is testing if this works", DIFFERENT(1,2));
|
||||||
|
}();
|
||||||
|
ADDPICKLE(Pickle_Deffinition_Test,Add_Pickle_Test);
|
||||||
|
ADDPICKLE(Pickle_Logic_Tests,Test_SAME);
|
||||||
|
ADDPICKLE(Pickle_Logic_Tests,Test_DIFFERENT);
|
||||||
|
PUTJARONSHLEF(Pickle_Logic_Tests);
|
||||||
|
PUTJARONSHLEF(Pickle_Deffinition_Test);
|
||||||
|
|
||||||
|
return __pickle_shelf_run(&__pickle_shelf__);
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user