[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / unittests / Remarks / RemarksAPITest.cpp
blob23a45e9a26556d011fbd854ce77fc73c53d50e02
1 //===- unittest/Support/RemarksAPITest.cpp - C++ API 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/Remarks/Remark.h"
10 #include "gtest/gtest.h"
12 using namespace llvm;
14 TEST(RemarksAPI, Comparison) {
15 remarks::Remark R;
16 R.RemarkType = remarks::Type::Missed;
17 R.PassName = "pass";
18 R.RemarkName = "name";
19 R.FunctionName = "func";
20 R.Loc = remarks::RemarkLocation{"path", 3, 4};
21 R.Hotness = 5;
22 R.Args.emplace_back();
23 R.Args.back().Key = "key";
24 R.Args.back().Val = "value";
25 R.Args.emplace_back();
26 R.Args.back().Key = "keydebug";
27 R.Args.back().Val = "valuedebug";
28 R.Args.back().Loc = remarks::RemarkLocation{"argpath", 6, 7};
30 // Check that == works.
31 EXPECT_EQ(R, R);
33 // Check that != works.
34 remarks::Remark R2 = R.clone();
35 R2.FunctionName = "func0";
36 EXPECT_NE(R, R2);
38 // Check that we iterate through all the arguments.
39 remarks::Remark R3 = R.clone();
40 R3.Args.back().Val = "not";
41 EXPECT_NE(R, R3);
44 TEST(RemarksAPI, Clone) {
45 remarks::Remark R;
46 R.RemarkType = remarks::Type::Missed;
47 R.PassName = "pass";
48 R.RemarkName = "name";
49 R.FunctionName = "func";
50 R.Loc = remarks::RemarkLocation{"path", 3, 4};
51 R.Hotness = 5;
52 R.Args.emplace_back();
53 R.Args.back().Key = "key";
54 R.Args.back().Val = "value";
55 R.Args.emplace_back();
56 R.Args.back().Key = "keydebug";
57 R.Args.back().Val = "valuedebug";
58 R.Args.back().Loc = remarks::RemarkLocation{"argpath", 6, 7};
60 // Check that clone works.
61 remarks::Remark R2 = R.clone();
62 EXPECT_EQ(R, R2);
65 TEST(RemarksAPI, ArgsAsMsg) {
66 remarks::Remark R;
67 R.RemarkType = remarks::Type::Missed;
68 R.Args.emplace_back();
69 R.Args.back().Key = "key";
70 R.Args.back().Val = "can not do this ";
71 R.Args.emplace_back();
72 R.Args.back().Key = "keydebug";
73 R.Args.back().Val = "because of that.";
74 R.Args.back().Loc = remarks::RemarkLocation{"argpath", 6, 7};
76 EXPECT_EQ(R.getArgsAsMsg(), "can not do this because of that.");