223 lines
6.1 KiB
Markdown
223 lines
6.1 KiB
Markdown
# Pickler
|
|
Have you ever just wanted pickles to the point where you needed them in your code.
|
|
Well do we have the test sweet for you. We prosent __PICKLER__ the _light weight_
|
|
unpickling API. Let me ask you this. Is your code _stuck in a pickle_ well, this
|
|
AIP will salve all of your _pickle stuck_ situations. Just include this into your
|
|
__cmake project__ and start writing with pickles.
|
|
|
|
# Techinal Definitions
|
|
So __PICKLER__ alows for unit testing with 100% natrual pickles. _Not the GMO testing
|
|
that you get with the googles goods._ Lets go back to basics, what is a pickle?
|
|
- __Pickle__ : Is a unit test.
|
|
- **Pickle_Jar** : This allows use to catagorize the pickles and tests them.
|
|
- **Pickle_Shelf** : This holds all of the *Pickle_Jars* and tests all of the
|
|
jars.
|
|
|
|
The definitions for passing a test are a little different. Here are the definitions.
|
|
|
|
- __Pickled__ : This means that a pickle test passed.
|
|
|
|
- __Droped the Pickle__ : This means that a pickle test failed.
|
|
|
|
- __Pickles In Jar__ : This means that all pickles passed.
|
|
|
|
- __Pickle Jar Broke__: This means that one or more of the pickles failed there
|
|
test.
|
|
|
|
- __Pickle Shelf Good__ : This means that all Pickle Jars passed.
|
|
|
|
- __Pickle Shelf Fell__ : This means that one or more Pickle Jars failed.
|
|
|
|
|
|
# How To Use
|
|
To init the Pickler Lib first include Pickler.h
|
|
```C++
|
|
#include "Pickler.h"
|
|
```
|
|
After includeing Pickler next we need to init Pickler. This is vary simple. Just
|
|
add into your `int main()` `INSTALLSHELF` This creates a safe place to put your pickle
|
|
jars.
|
|
```C++
|
|
#include "Pickler.h"
|
|
|
|
int main() {
|
|
// init the shelf
|
|
INSTALLSHELF();
|
|
}
|
|
```
|
|
Once The shelf is created we can create __Pickle Jars__. To Create a pickle jar
|
|
call `CREATEJAR(name)` This will create a pickle jar. The __Pickle Jar must be created
|
|
after the shelf.__ The Pickle Jar requires a name. __This name should be entererd in
|
|
plain text and with no speshial characters and should be treated like a varaible name.__
|
|
```C++
|
|
#include "Pickler.h"
|
|
|
|
int main() {
|
|
// init the shelf
|
|
INSTALLSHELF();
|
|
// Creating Pickle Jar
|
|
CREATEJAR(jar_name);
|
|
}
|
|
```
|
|
Next we can make __Pickles__. To Create a Pickle just use the `PICKLE' macro.
|
|
Treate this like a lambda expretion. A Pickle should look like this.
|
|
```C++
|
|
#include "Pickler.h"
|
|
|
|
int main() {
|
|
// init the shelf
|
|
INSTALLSHELF();
|
|
|
|
// Creating Pickle Jar
|
|
CREATEJAR(jar_name);
|
|
|
|
// Creating a pickle
|
|
PICKLE(pickle_name) {
|
|
// test contents.
|
|
}();
|
|
PICKLE(pickle_name2) {
|
|
// test contents.
|
|
}();
|
|
}
|
|
```
|
|
To make the pickle functions not throw a error you must add a `ASSERT(message, passed)`. The assert
|
|
will reporte to the pickle jar to tell the pickle jar to see if the _pickle was droped_
|
|
or was _pickled_. (Faled or Successed). Here is how to use the `ASSERT(message, passed)`.
|
|
```C++
|
|
#include "Pickler.h"
|
|
|
|
int main() {
|
|
// init the shelf
|
|
INSTALLSHELF();
|
|
|
|
// Creating Pickle Jar
|
|
CREATEJAR(jar_name);
|
|
|
|
// Creating a pickle
|
|
PICKLE(pickle_name) {
|
|
// test contents.
|
|
ASSERT("This is a test that will faile", false)
|
|
}();
|
|
PICKLE(pickle_name2) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", true)
|
|
}();
|
|
}
|
|
```
|
|
There are two objects that will make the assert a little easier to use. There is
|
|
`SAME(value1,value2)` and `DIFFERENT(value1,value2)` that will test to see if the
|
|
objects are the same or they are different.
|
|
```C++
|
|
#include "Pickler.h"
|
|
|
|
int main() {
|
|
// init the shelf
|
|
INSTALLSHELF();
|
|
|
|
// Creating Pickle Jar
|
|
CREATEJAR(jar_name);
|
|
|
|
// Creating a pickle
|
|
PICKLE(pickle_name) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", DIFFERENT(1,2))
|
|
}();
|
|
PICKLE(pickle_name2) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", SAME(2,2))
|
|
}();
|
|
}
|
|
```
|
|
Now we need to add pickles to the pickle jar. To add pickles to the pickle jar use
|
|
`ADDPICKLE(jar,pickle)` to add a pickle to a pickle jar.
|
|
```C++
|
|
#include "Pickler.h"
|
|
|
|
int main() {
|
|
// init the shelf
|
|
INSTALLSHELF();
|
|
|
|
// Creating Pickle Jar
|
|
CREATEJAR(jar_name);
|
|
|
|
// Creating a pickle
|
|
PICKLE(pickle_name) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", DIFFERENT(1,2))
|
|
}();
|
|
PICKLE(pickle_name2) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", SAME(2,2))
|
|
}();
|
|
|
|
// Adding pickls to pickle jar
|
|
ADDPICKLE(jar_name, pickle_name);
|
|
ADDPICKLE(jar_name, pickle_name2);
|
|
}
|
|
```
|
|
The pickles have now been added to the pickle jar, but now we need to add the
|
|
pickle jar to the pickle shelf. To do this just simply add `PUTJARONSHELF(jar)`.
|
|
This macro will add the pickle jar to the shelf.
|
|
```C++
|
|
#include "Pickler.h"
|
|
|
|
int main() {
|
|
// init the shelf
|
|
INSTALLSHELF();
|
|
|
|
// Creating Pickle Jar
|
|
CREATEJAR(jar_name);
|
|
|
|
// Creating a pickle
|
|
PICKLE(pickle_name) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", DIFFERENT(1,2))
|
|
}();
|
|
PICKLE(pickle_name2) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", SAME(2,2))
|
|
}();
|
|
|
|
// Adding pickls to pickle jar
|
|
ADDPICKLE(jar_name, pickle_name);
|
|
ADDPICKLE(jar_name, pickle_name2);
|
|
|
|
// Adding pickle jar to pickle shelf.
|
|
PUTJARONSHELF(jar_name);
|
|
}
|
|
```
|
|
Now The last step to use Pickler. For the return of main just return `PICKLESHELF`.
|
|
Thats it.
|
|
```C++
|
|
#include "Pickler.h"
|
|
|
|
int main() {
|
|
// init the shelf
|
|
INSTALLSHELF();
|
|
|
|
// Creating Pickle Jar
|
|
CREATEJAR(jar_name);
|
|
|
|
// Creating a pickle
|
|
PICKLE(pickle_name) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", DIFFERENT(1,2))
|
|
}();
|
|
PICKLE(pickle_name2) {
|
|
// test contents.
|
|
ASSERT("This is a test that will successed", SAME(2,2))
|
|
}();
|
|
|
|
// Adding pickls to pickle jar
|
|
ADDPICKLE(jar_name, pickle_name);
|
|
ADDPICKLE(jar_name, pickle_name2);
|
|
|
|
// Adding pickle jar to pickle shelf.
|
|
PUTJARONSHELF(jar_name);
|
|
|
|
return PICKLESHELF;
|
|
}
|
|
```
|
|
Now you are a master of pickling software. Use these skills as a Pickler master
|
|
wizly because now you hold a great power of pickling software.
|