| 1 | //===-- RIFFTests.cpp - Binary container unit tests -----------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "RIFF.h" |
| 10 | #include "llvm/Support/ScopedPrinter.h" |
| 11 | #include "gmock/gmock.h" |
| 12 | #include "gtest/gtest.h" |
| 13 | |
| 14 | namespace clang { |
| 15 | namespace clangd { |
| 16 | namespace { |
| 17 | |
| 18 | TEST(RIFFTest, File) { |
| 19 | riff::File File{.Type: riff::fourCC(Literal: "test" ), |
| 20 | .Chunks: { |
| 21 | {.ID: riff::fourCC(Literal: "even" ), .Data: "abcd" }, |
| 22 | {.ID: riff::fourCC(Literal: "oddd" ), .Data: "abcde" }, |
| 23 | }}; |
| 24 | llvm::StringRef Serialized = llvm::StringRef("RIFF\x1e\0\0\0test" |
| 25 | "even\x04\0\0\0abcd" |
| 26 | "oddd\x05\0\0\0abcde\0" , |
| 27 | 38); |
| 28 | |
| 29 | EXPECT_EQ(llvm::to_string(File), Serialized); |
| 30 | auto Parsed = riff::readFile(Stream: Serialized); |
| 31 | ASSERT_TRUE(bool(Parsed)) << Parsed.takeError(); |
| 32 | EXPECT_EQ(*Parsed, File); |
| 33 | } |
| 34 | |
| 35 | } // namespace |
| 36 | } // namespace clangd |
| 37 | } // namespace clang |
| 38 | |