#include <iostream>
#include "../include/RamLock.h"

using namespace std;
using namespace environnement;
using namespace environnement::ramlock;


#define TEST(x,y)				\
  {						\
    cout << "Line " << __LINE__ << " : ";	\
    if (x==y)					\
      {						\
	cout << "Test OK";			\
      }						\
    else					\
      {						\
	cout << "Test KO";			\
	exit (EXIT_FAILURE);			\
      }						\
    cout << endl;				\
  } while (0)
    


int main (void)
{
  cout << "<main> Begin" << endl;

  cout << "  * Create a Ramlock with a size of 70" << endl;

  Parameters * param      = new Parameters (70);
  RamLock    * my_ramlock = new RamLock("my_ramlock",param);

  my_ramlock->reset();

  cout << *my_ramlock << endl;

  TEST (my_ramlock->read (10) , UNLOCK);  cout << *my_ramlock << endl;
  TEST (my_ramlock->read (10) ,   LOCK);  cout << *my_ramlock << endl;
  TEST (my_ramlock->write(10) ,   LOCK);  cout << *my_ramlock << endl;
  TEST (my_ramlock->write(10) , UNLOCK);  cout << *my_ramlock << endl;

  delete param      ;
  delete my_ramlock ;
  
  cout << "<main> End" << endl;

  return EXIT_SUCCESS;
}
