-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest_toolchain_stdmod.cpp
More file actions
72 lines (60 loc) · 1.99 KB
/
Copy pathtest_toolchain_stdmod.cpp
File metadata and controls
72 lines (60 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <gtest/gtest.h>
import std;
import mcpp.toolchain.clang;
import mcpp.toolchain.gcc;
import mcpp.toolchain.model;
using namespace mcpp::toolchain;
namespace {
Toolchain gcc_toolchain() {
Toolchain tc;
tc.compiler = CompilerId::GCC;
tc.version = "16.1.0";
tc.binaryPath = "g++";
tc.targetTriple = "x86_64-linux-gnu";
tc.stdlibId = "libstdc++";
tc.stdlibVersion = "16.1.0";
tc.stdModuleSource = "bits/std.cc";
return tc;
}
Toolchain clang_toolchain() {
Toolchain tc;
tc.compiler = CompilerId::Clang;
tc.version = "20.1.7";
tc.binaryPath = "clang++";
tc.targetTriple = "x86_64-linux-gnu";
tc.stdlibId = "libc++";
tc.stdlibVersion = "20.1.7";
tc.stdModuleSource = "std.cppm";
tc.stdCompatSource = "std.compat.cppm";
return tc;
}
} // namespace
TEST(ToolchainStdmod, GccStdModuleCommandUsesRequestedStandard) {
auto cmd = gcc::std_module_build_command(
gcc_toolchain(), "cache", "", "-std=c++26");
EXPECT_NE(cmd.find("-std=c++26"), std::string::npos) << cmd;
EXPECT_EQ(cmd.find("-std=c++23"), std::string::npos) << cmd;
}
TEST(ToolchainStdmod, ClangStdModuleCommandsUseRequestedStandard) {
auto cmds = clang::std_module_build_commands(
clang_toolchain(), "cache", "cache/pcm.cache/std.pcm", "", "-std=c++26");
ASSERT_EQ(cmds.size(), 2u);
for (auto const& cmd : cmds) {
EXPECT_NE(cmd.find("-std=c++26"), std::string::npos) << cmd;
EXPECT_EQ(cmd.find("-std=c++23"), std::string::npos) << cmd;
}
}
TEST(ToolchainStdmod, ClangStdCompatCommandsUseRequestedStandard) {
auto cmds = clang::std_compat_build_commands(
clang_toolchain(),
"cache",
"cache/pcm.cache/std.compat.pcm",
"cache/pcm.cache/std.pcm",
"",
"-std=c++26");
ASSERT_EQ(cmds.size(), 2u);
for (auto const& cmd : cmds) {
EXPECT_NE(cmd.find("-std=c++26"), std::string::npos) << cmd;
EXPECT_EQ(cmd.find("-std=c++23"), std::string::npos) << cmd;
}
}