I've done embedded software at work. And still do. I've seen a memory test - provided in source code format by a chip vendor - that failed to identify broken or incorrectly soldered memory chips.
Two different kinds of memory tests are needed: Ones that exercise the memory byte-by-byte or word-by-word and ones that exercise the address lines.
1) All ones, all zeros and 0x01010101 written one memory address at a time are of the first category (exercise each memory location). So is the classic "walking bit" where you walk first a 1-bit through a memory location (with all other bits being zero) and then continue this from the next memory location until end of memory. Once the whole memory is tested this way you'd follow this up with a walking 0-bit test.
This category of tests proves that each of the data lines works and that each memory location works assuming the address lines worked correctly. And that is an assumption that needs to be verified next.
2) This category of tests verifies that all address lines work correctly and that each memory location really is a separate memory location. Here you need to first fill the whole memory with some non-repeating pattern (or a pattern that does not have a cycle length divisible by 8) and then read it back verifying that each memory address returns what was written there. You could use the fibonacci sequence (1, 1, 2, 3, 5, 8, ...) for this (use unsigned integers for the math; yes it will overflow but that does not matter as there should always be enough variance in the least significant bits that are left after an overflow...) Or you could just write "memory address + 11" to each memory location (the +11 is arbitrary but important as you don't want to use the same data as the memory address...). Anyway, write all memory addresses with your chosen sequence first and then read back all memory addresses and verify that the expected data is there.
Why is the category 2 test needed? Well, assume you have a 16-bit system (64k addresses) that has a solder bridge between the two most significant address line bits. Or a broken memory chip that internally shadows the upper half of its memory on top of the lower half. The first category of tests is not going to catch that. What will be seen is that the lower 32k of memory works correctly and the upper 32k of memory works correctly when tested byte-by-byte or in blocks less than 32k, but once the whole memory is tested at once it will be noticed that the upper 32k is the same as the lower 32k...
Actually if testing byte-by-byte even totally unconnected data lines might pass the test if there was a sufficient amount of stray capacitance on the data lines...
My real-world experience with the memory test that didn't find problems was only doing the category 1 test, I think it was doing the walking bit test. This kind of test is ok if you are looking for random errors in memory that is otherwise working ok, but not ok for finding soldering mistakes in production or badly misbehaving memory chips.