I had trouble putting some data on a newly-purchased usb thumb drive and wanted to find the cause. I heard of fake usb drives claiming to be bigger than the actual flash. Those simply write cyclically to the drive, erasing earlier data.
So I wrote a simple program to test my usb thumb drive. It writes successive numbers (each 8 bytes wide) to the thumb drive. For each block of 1024 written numbers, one randomly chosen, previously written block is read and verified.
In case of a fake drive, it is expected, that a complete later block appears at an earlier position. For a broken drive, it is expected to read some garbage at any position.
My usb thumb drive pretty quickly yielded the latter: "Byte 7A744FEE3E5475D7 an Stelle 000000000551C000".