Skip to content

jsdevel/cpp-unit-testing

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"

using namespace std;

#define USE_BEFORE 1
#define USE_AFTER 1
#include "helpers/assert.h"
namespace test {
  PWM * pwm;

  void before(){
    pwm = new PWM(5, 30, 1000);
  }

  void after(){
    pwm = 0;
  }

  void valid_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++){
      PWM pwm(pins[i], 0, 1);
    }
  }

  void invalid_pins_for_constructor_throw_error(){
    int pins [5] = {1, 2, 0, 40, 50};
    for(int i = 0;i<5;i++){
      try {
        PWM pwm(pins[i], 0, 1);
        fail("didn't throw for");
      } catch(...){
        continue;
      }
    }
  }
}

int main(){
  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

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages