[docs] Fix build-docs.sh
[llvm-project.git] / llvm / unittests / Option / OptionMarshallingTest.cpp
blob85f0d86a8696800c31a619fe6ca9506e8e10757e
1 //===- unittest/Support/OptionMarshallingTest.cpp - OptParserEmitter 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 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 struct OptionWithMarshallingInfo {
12 const char *Name;
13 const char *KeyPath;
14 const char *ImpliedCheck;
15 const char *ImpliedValue;
18 static const OptionWithMarshallingInfo MarshallingTable[] = {
19 #define OPTION_WITH_MARSHALLING( \
20 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
21 HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \
22 DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
23 MERGER, EXTRACTOR, TABLE_INDEX) \
24 {NAME, #KEYPATH, #IMPLIED_CHECK, #IMPLIED_VALUE},
25 #include "Opts.inc"
26 #undef OPTION_WITH_MARSHALLING
29 TEST(OptionMarshalling, EmittedOrderSameAsDefinitionOrder) {
30 ASSERT_STREQ(MarshallingTable[0].Name, "marshalled-flag-d");
31 ASSERT_STREQ(MarshallingTable[1].Name, "marshalled-flag-c");
32 ASSERT_STREQ(MarshallingTable[2].Name, "marshalled-flag-b");
33 ASSERT_STREQ(MarshallingTable[3].Name, "marshalled-flag-a");
36 TEST(OptionMarshalling, EmittedSpecifiedKeyPath) {
37 ASSERT_STREQ(MarshallingTable[0].KeyPath, "X->MarshalledFlagD");
38 ASSERT_STREQ(MarshallingTable[1].KeyPath, "X->MarshalledFlagC");
39 ASSERT_STREQ(MarshallingTable[2].KeyPath, "X->MarshalledFlagB");
40 ASSERT_STREQ(MarshallingTable[3].KeyPath, "X->MarshalledFlagA");
43 TEST(OptionMarshalling, ImpliedCheckContainsDisjunctionOfKeypaths) {
44 ASSERT_STREQ(MarshallingTable[0].ImpliedCheck, "false");
46 ASSERT_STREQ(MarshallingTable[1].ImpliedCheck, "false || X->MarshalledFlagD");
47 ASSERT_STREQ(MarshallingTable[1].ImpliedValue, "true");
49 ASSERT_STREQ(MarshallingTable[2].ImpliedCheck, "false || X->MarshalledFlagD");
50 ASSERT_STREQ(MarshallingTable[2].ImpliedValue, "true");
52 ASSERT_STREQ(MarshallingTable[3].ImpliedCheck,
53 "false || X->MarshalledFlagC || X->MarshalledFlagB");
54 ASSERT_STREQ(MarshallingTable[3].ImpliedValue, "true");