blob: 83997f08a4224da0edd4339e0762e9e9866a2b36 [file] [log] [blame]
Marcel Hlopkob10e49b2022-05-09 03:57:32 -07001// Part of the Crubit project, under the Apache License v2.0 with LLVM
2// Exceptions. See /LICENSE for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#include "rs_bindings_from_cc/collect_instantiations.h"
6
7#include <climits>
8
Luca Versaric21d92f2022-05-25 00:56:30 -07009#include "gmock/gmock.h"
10#include "gtest/gtest.h"
11#include "common/status_test_matchers.h"
Marcel Hlopkob10e49b2022-05-09 03:57:32 -070012#include "common/test_utils.h"
13
14namespace crubit {
15namespace {
16
17using ::testing::ElementsAre;
18using ::testing::IsEmpty;
19using ::testing::StrEq;
Marcel Hlopkob10e49b2022-05-09 03:57:32 -070020
21// A minimal test showing that C++ and Rust link and talk to each other.
22TEST(CollectInstantiationsTest, EmptyRustFileReturnsEmptyCollectionTest) {
23 EXPECT_THAT(CollectInstantiations({}), IsOkAndHolds(IsEmpty()));
24}
25
26// A minimal test showing that C++ and Rust link and talk to each other.
27TEST(CollectInstantiationsTest, ReturnInstantiationsFromRustTest) {
28 std::string path =
29 WriteFileForCurrentTest("a.rs", "cc_template!(std::vector<bool>);");
30 EXPECT_THAT(CollectInstantiations({std::move(path)}),
Lukasz Anforowicz51953ac2022-10-05 07:29:18 -070031 IsOkAndHolds(ElementsAre(StrEq("std :: vector < bool >"))));
Marcel Hlopkob10e49b2022-05-09 03:57:32 -070032}
33
34} // namespace
35} // namespace crubit