Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

9 Commits

Repository files navigation

cpp-unit-testing

A single header file is all you need :)

The goal of this project is to allow testing of c++ to remain easy and flexible, without the need to install libraries. You can simply copy the header file into your project to get started.

##Example

#include<cstdio>
#include<iostream>
#include"../../src/cc/PWM.h"usingnamespacestd;
#defineUSE_BEFORE1
#defineUSE_AFTER1
#include"helpers/assert.h"namespacetest {
PWM * pwm;
voidbefore(){
pwm = newPWM(5, 30, 1000);
}
voidafter(){
pwm = 0;
}
voidvalid_pins_for_constructor_throw_no_error(){
int pins [17] = {3, 5, 7, 8, 10, 11, 12, 13, 15, 16, 18, 19, 21, 22, 23, 24, 26};
for(int i = 0;i<17;i++){
PWMpwm(pins[i], 0, 1);
}
}
voidinvalid_pins_for_constructor_throw_error(){
int pins [5] = {1, 2, 0, 40, 50};
for(int i = 0;i<5;i++){
try {
PWMpwm(pins[i], 0, 1);
fail("didn't throw for");
} catch(...){
continue;
}
}
}
}
intmain(){
SUITE();
TEST(valid_pins_for_constructor_throw_no_error);
TEST(invalid_pins_for_constructor_throw_error);
END();
}

About

A single header file is all you need :)

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages