dm41nes:
The code in its simplest form is to check if the outputs = inputs (automated cable continuity test). The optocouplers are there for electrical isolation of the cable which will be connected between the optocouplers
The way you have wired it - with the same power supply - there is no electrical isolation between the two. You'll have to get a completely independent power supply for the cable.
Other than that it should just work - as long as you add a delay of at least 40 µs between setting the output and reading the input to allow for the optocouplers to do their thing.
That said, if all you want to do is check continuity, why not power supply + resistor + LED? A microprocessor sounds like total overkill for this.