[lldb] Fix "exact match" debug_names type queries (#118465)
[llvm-project.git] / llvm / unittests / Option / OptionMarshallingTest.cpp
blob2ec422f1a098436b17410a7990aa96a092c146d5
1 //===- OptionMarshallingTest.cpp - OptionParserEmitter 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 "llvm/ADT/StringRef.h"
10 #include "gtest/gtest.h"
12 struct OptionWithMarshallingInfo {
13 llvm::StringLiteral PrefixedName;
14 const char *KeyPath;
15 const char *ImpliedCheck;
16 const char *ImpliedValue;
19 static const OptionWithMarshallingInfo MarshallingTable[] = {
20 #define OPTION_WITH_MARSHALLING( \
21 PREFIX_TYPE, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
22 VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
23 SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK, \
24 IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX) \
25 {PREFIXED_NAME, #KEYPATH, #IMPLIED_CHECK, #IMPLIED_VALUE},
26 #include "Opts.inc"
27 #undef OPTION_WITH_MARSHALLING
30 TEST(OptionMarshalling, EmittedOrderSameAsDefinitionOrder) {
31 ASSERT_EQ(MarshallingTable[0].PrefixedName, "-marshalled-flag-d");
32 ASSERT_EQ(MarshallingTable[1].PrefixedName, "-marshalled-flag-c");
33 ASSERT_EQ(MarshallingTable[2].PrefixedName, "-marshalled-flag-b");
34 ASSERT_EQ(MarshallingTable[3].PrefixedName, "-marshalled-flag-a");
37 TEST(OptionMarshalling, EmittedSpecifiedKeyPath) {
38 ASSERT_STREQ(MarshallingTable[0].KeyPath, "X->MarshalledFlagD");
39 ASSERT_STREQ(MarshallingTable[1].KeyPath, "X->MarshalledFlagC");
40 ASSERT_STREQ(MarshallingTable[2].KeyPath, "X->MarshalledFlagB");
41 ASSERT_STREQ(MarshallingTable[3].KeyPath, "X->MarshalledFlagA");
44 TEST(OptionMarshalling, ImpliedCheckContainsDisjunctionOfKeypaths) {
45 ASSERT_STREQ(MarshallingTable[0].ImpliedCheck, "false");
47 ASSERT_STREQ(MarshallingTable[1].ImpliedCheck, "false || X->MarshalledFlagD");
48 ASSERT_STREQ(MarshallingTable[1].ImpliedValue, "true");
50 ASSERT_STREQ(MarshallingTable[2].ImpliedCheck, "false || X->MarshalledFlagD");
51 ASSERT_STREQ(MarshallingTable[2].ImpliedValue, "true");
53 ASSERT_STREQ(MarshallingTable[3].ImpliedCheck,
54 "false || X->MarshalledFlagC || X->MarshalledFlagB");
55 ASSERT_STREQ(MarshallingTable[3].ImpliedValue, "true");