// DSA Lab 1

#include <iostream>
#include "buffer.h"

// Fill up a buffer with the numbers 1-10.
void FillTen(buffer & b)
{
  for (int i=1; i <= 10; ++i)
    b.add(i);
}

void main()
{
  const int maxsize = 20;
  buffer b1(maxsize);
  buffer b2(maxsize);
  buffer b3(maxsize);
  int i;

  std::cout << "Test 1: add, then remove numbers 1-10." << std::endl;
  for (i=1; i <= 10; ++i)
    b1.add(i);
  std::cout << "contents:" << std::endl << "\t";
  for (i=1; i <= 10; ++i)
    std::cout << b1.remove() << "  ";
  std::cout << std::endl;

  std::cout << "\nTest 2: fill and exceed capacity of buffer." << std::endl;
  for (i=1; i <= 2 * maxsize; ++i)
    b2.add(i);
  std::cout << "actual size:" << b2.size() << std::endl;

  std::cout << "\nTest 3: add using function call, then remove" << std::endl;
  FillTen(b3);
  std::cout << "actual size:" << b3.size() << std::endl;
  std::cout << "contents:" << std::endl << "\t";
  for (i=1; i <= 10; ++ i)
    std::cout << b3.remove() << "  ";
  std::cout << std::endl;

  std::cout << "\nTest 4: assigning one buffer to another:" << std::endl;
  b3 = b2;  
  for (i=1; i <= 19; ++i)
    b3.remove();
  for (i=1; i <= 10; ++i)
        b3.add(99);
  std::cout << "b3's contents:" << std::endl << "\t";
  for (i=1; i <= 10; ++i)
    std::cout << b3.remove() << "  ";
  std::cout << std::endl;
  std::cout << "b2's contents:" << std::endl << "\t";
  for (i=1; i <= 19; ++i)
    std::cout << b2.remove() << "  ";
  std::cout << std::endl;

  void test_sorted();
  test_sorted();
}
