1 //===- unittest/Support/RemarksAPITest.cpp - C++ API tests ----------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Remarks/Remark.h"
10 #include "gtest/gtest.h"
14 TEST(RemarksAPI
, Comparison
) {
16 R
.RemarkType
= remarks::Type::Missed
;
18 R
.RemarkName
= "name";
19 R
.FunctionName
= "func";
20 R
.Loc
= remarks::RemarkLocation
{"path", 3, 4};
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.
33 // Check that != works.
34 remarks::Remark R2
= R
.clone();
35 R2
.FunctionName
= "func0";
38 // Check that we iterate through all the arguments.
39 remarks::Remark R3
= R
.clone();
40 R3
.Args
.back().Val
= "not";
44 TEST(RemarksAPI
, Clone
) {
46 R
.RemarkType
= remarks::Type::Missed
;
48 R
.RemarkName
= "name";
49 R
.FunctionName
= "func";
50 R
.Loc
= remarks::RemarkLocation
{"path", 3, 4};
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();
65 TEST(RemarksAPI
, ArgsAsMsg
) {
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.");