Array Pin Test Help

Hi,

I am stuck on a programming problem and not sure what direction I should take it. I have a number of pins connected to various plugs and need to check for shorts and continuity between various pins. I have setup an array for the pins that I am using, what the program does is enabled all pull ups for the test pins and then lowers the current test pin and check for any of the other pins to be low. What I am having issues with is that a few pins are connected to each other whilst the others are completely isolated. I need to decipher between these and legitimate shorts. for example test pin 4 is connected to 23.

void HardwareTest()
{
                
       
     
        
         //Test pin function
         //******
        
               
         //Set Test pin low
         //Test all pullups for low condition indicate shorts
         
       
        int testPins[] = { 4, 14, 5, 6, 15, 25, 23, 29, 18, 43, 19, 27, 31, 45, 35, 33};
        int testpinCount = 16;
        
        for (int i = 0; i < testpinCount; i++)
        {
          //turn on required pullups
          TestPullUpsOn();
          //Set Test pin to output low
          pinMode(testPins[i],OUTPUT);
          digitalWrite(testPins[i],LOW);
          
          //Test all other pins in array to see if they are low 
          for (int j = 0; j < testpinCount; j++)
          {
           if (i != j && ((testPins[i] != 4) && (testPins[j] != 23)))  //NOT SURE WHAT TEST CONDITIONS I NEED TO IMPLEMENT
                 //THIS IS WHERE I NEED HELP
            {
              int pinstate = digitalRead(testPins[j]);
              
              if (pinstate == LOW)
              {
                //need to compare the pins that are low with what was tested and what it should be connected too
                //for example RJRX 4 is connected to DBMO 23 etc
                 Serial.write("i\n");
                  Serial.println(testPins[i]);
                  Serial.write("j\n");
                  Serial.println(testPins[j]);
                  
                

              
              
            }
            
          }
        }
        
       // testState = TESTIDLE;

}

void TestPullUpsOn()
{
  
    int testPins[] = { 4, 14, 5, 6, 15, 25, 23, 29, 18, 43, 19, 27, 31, 45, 35, 33};
        int testpinCount = 16;
        
        for (int i = 0; i < testpinCount; i++)
        {
          //turn on required pullups
          //Set Test pin to output low
          pinMode(testPins[i],INPUT);
          digitalWrite(testPins[i],HIGH);
        }
         
}

When I test the above code it allows pin 4 and 23 to be connected but if any other pin is also connected to pin 4 or 23 lets say 5 the code will run through and not detect the short.

Anyway I am not sure if this is the right approach or not any other suggestions or other testing techniques would be greatly appreciated.

:EDIT reworded to make more sense.

Thanks,
Stolzie

         if (i != j && 
             !((testPins[i] == 4) && (testPins[j] == 23)) && 
             !((testPins[i] == 23) && (testPins[j] == 4)))