Tests for simple blinky library.

Dependencies:   Blinky

Fork of Blinky_Tests by Sarah Marsh

Revision:
4:09af3b2d723e
Parent:
2:a6755ef75598
Child:
5:4f1e6b065e6b
diff -r 4432e591b5ef -r 09af3b2d723e TESTS/Blinky/5_Blinks/main.cpp
--- a/TESTS/Blinky/5_Blinks/main.cpp	Tue Nov 08 18:51:34 2016 +0000
+++ b/TESTS/Blinky/5_Blinks/main.cpp	Tue Nov 08 22:12:16 2016 +0000
@@ -10,35 +10,25 @@
 //All tests will blink the LED 5 times
 const int expected_blinks = 5;
 //To be set by interrupt handler
-int measured_blinks = 0;
- 
-//To be called by interrupt, increases the number of measured rising edges 
-void count_blinks(){
-    measured_blinks++;
-}
  
 //Generic blink test
 //interval => the the amount of time between blinks
 //led => PinName of LED to blink
 void test_blinks(PinName led, int interval){
-    //reset the measured blinks to 0 for each case
-    measured_blinks = 0;
     //Set an appropriate wait time to measure exactly expected_blinks
     //with the given interval 
     float wait_time = 2*interval*expected_blinks;
-    //Create an interrupt that calls count_blinks on rising edge of LED pin
-    InterruptIn blink_counter(led);
     //Create Blinky
     Blinky blinker(led, interval);
-    //Attach interrupt
-    blink_counter.rise(&count_blinks);
     //start blinky
     blinker.start();
     //Wait the appropriate amount of time for expected_blinks 
     Thread::wait(wait_time);
     blinker.stop();
+    
+    float measured_blinks = blinker.times_blinked();
     //Only assert if failure
-    TEST_ASSERT(measured_blinks != expected_blinks);
+    TEST_ASSERT(measured_blinks == (float)expected_blinks);
 }
  
 void blink_500(){