//----------------------------------------------------------------------
//  testpbx.cpp
//  This is a test program for the modified version
//  of PbxCalls stored in files pbxcallt.h and .cpp
//----------------------------------------------------------------------
#include "pbxcallt.h"
#include <iostream.h>

int main()
{
    PhoneNumType ph[30];
    int          i;
    Boolean      busy;
    PbxType      pbx;

    for (i = 1; i < 30; i++)
        if (i%2 == 1)
            ph[i] = 1000 + i;
        else
            ph[i] = 2000 + i;

    pbx.Dial(ph[1],ph[2],11,busy);
    if (busy) cout << "Busy ERROR 1\n";
    cout <<  "Call placed from 1 to 2\n"
         <<  "-----------------------\n";
    pbx.Dump();
    pbx.Dial(ph[1],ph[2],22,busy);
    if ( !busy ) cout << "Busy ERROR 2\n";
    pbx.Dial(ph[2],ph[3],33,busy);
    if ( !busy ) cout << "Busy ERROR 3\n";
    pbx.Dial(ph[1],ph[3],44,busy);
    if ( !busy ) cout << "Busy ERROR 4\n";

    pbx.Dial(ph[3],ph[4],55,busy);
    if (busy) cout << "Busy ERROR 5\n";
    pbx.Dial(ph[5],ph[6],56,busy);
    if (busy) cout << "Busy ERROR 6\n";
    pbx.Dial(ph[7],ph[8],57,busy);
    if (busy) cout << "Busy ERROR 7\n";
    pbx.Dial(ph[9],ph[10],58,busy);
    if (busy) cout << "Busy ERROR 8\n";
    pbx.Dial(ph[11],ph[12],59,busy);
    if (busy) cout << "Busy ERROR 9\n";
    pbx.Dial(ph[13],ph[14],60,busy);
    if (busy) cout << "Busy ERROR 10\n";
    pbx.Dial(ph[15],ph[16],61,busy);
    if (busy) cout << "Busy ERROR 11\n";
    pbx.Dial(ph[17],ph[18],58,busy);
    if (busy) cout << "Busy ERROR 12\n";
    cout <<  "Call placed from 3 thru 18 in pairs\n"
         <<  "-----------------------------------\n";
    pbx.Dump();

    pbx.Dial(ph[20],ph[21],58,busy);
    if ( !busy ) cout << "Busy ERROR 13\n";
    pbx.HangUp(ph[16],77);
    cout <<  "caller 16 hung up\n"
         <<  "-----------------\n";
    pbx.Dump();

    pbx.Dial(ph[20],ph[21],59,busy);
    if (busy) cout << "Busy ERROR 14\n";
    pbx.HangUp(ph[1],78);
    pbx.HangUp(ph[5],79);
    pbx.HangUp(ph[10],80);
    pbx.HangUp(ph[28],81);

    cout <<  "callers 1, 5, 10 and 28 hung up\n"
         <<  "-------------------------------\n";
    pbx.Dump();

    pbx.Dial(ph[22],ph[23],60,busy);
    if (busy) cout << "Busy ERROR 15\n";
    pbx.SortLines();
    cout <<  "Dial 22 to 23 & sort\n"
         <<  "--------------------\n";
    pbx.Dump();
    return 0;
}

