https://en.wikipedia.org/wiki/New_European_Driving_Cycle
https://en.wikipedia.org/wiki/FTP-75
The problem with the testing is that it also followed the exact same unit test. I have not read the law, but they certainly violated the spirit of the law if not also the letter.
What VW did do was more interesting and could be interpreted as exploiting a loophole in the law. They very precisely met the requirements of the emissions test as it was written in the law. I see this as a regulation failure and should be used to inform future emission laws and testing.
This whole video is interesting but at least watch starting at this point to see how clever VW engineers are:
https://media.ccc.de/v/32c3-7331-the_exhaust_emissions_scand...
If there had not been such a public outcry VW might have pushed back saying they are in compliance with the law as written.