const byte PinOut [] = { 10, 9, 8 };
const byte PinInp [] = {  5, 6, 7 };
const int  Npin      = sizeof(PinInp);

char s [90];

// -----------------------------------------------------------------------------
void
fault (
    byte pinOut,
    byte pinInp,
    int  lvl )
{
    if (pinOut == pinInp)
        sprintf (s, "fault: %d %d %s - non-conductive",
                                    pinOut, pinInp, lvl ? "H" : "L" );
    else
        sprintf (s, "fault: %d %d %s - cross-connect",
                                    pinOut, pinInp, lvl ? "H" : "L" );
    Serial.println (s);
}

// -----------------------------------------------------------------------------
void
test (void)
{
    for (int n = 0; n < Npin; n++)  {
        digitalWrite (PinOut [n], LOW);     // pull low

        for (int i = 0; i < Npin; i++)  {
            byte inp = digitalRead (PinInp [i]);

            if (n == i)  {
                if (LOW != inp)
                    fault (n, i, inp);
            }
            else  {
                if (LOW == inp)
                    fault (n, i, inp);
            }
        }

        digitalWrite (PinOut [n], HIGH);
    }
}

// -----------------------------------------------------------------------------
void
setup (void)
{
    Serial.begin (9600);

    for (int n = 0; n < Npin; n++)  {
        pinMode      (PinInp [n], INPUT_PULLUP);
        pinMode      (PinOut [n], OUTPUT);
        digitalWrite (PinOut [n], HIGH);
    }

    test ();
}

void
loop (void)
{
}