You have two basic options. The first option, asyou said, is to read the actual file and compare its contents, or call filesystem APIs and verify that their results match with EXPECT_EQ, and so on. (And there are techniques you can use to speed that up, such as writing to a tmpfs on Linux.) The second option is to modify your system under test to use an interface for writing files, instead of directly calling the OS file APIs itself. In production, you can use an implementation of this interface that does actual file writes, while the tests use a mock that validates that the expected interface calls occur but skips the actual file operations for performance. For more information on this second approach, you can read up on Google Mock or other mocking implementations.
--
Josh Kelley