Replace existing test code with gtest-based tests

Build gtest in platform-specific directory.