1 //===- BPFunctionNodeTest.cpp - BPFunctionNode 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/ProfileData/InstrProf.h"
10 #include "llvm/Support/BalancedPartitioning.h"
11 #include "llvm/Testing/Support/SupportHelpers.h"
12 #include "gmock/gmock.h"
13 #include "gtest/gtest.h"
16 using testing::UnorderedElementsAre
;
17 using testing::UnorderedElementsAreArray
;
21 void PrintTo(const BPFunctionNode
&Node
, std::ostream
*OS
) {
22 raw_os_ostream
ROS(*OS
);
26 TEST(BPFunctionNodeTest
, Basic
) {
27 auto Nodes
= TemporalProfTraceTy::createBPFunctionNodes({
28 TemporalProfTraceTy({0, 1, 2, 3, 4}),
29 TemporalProfTraceTy({4, 2}),
32 auto NodeIs
= [](BPFunctionNode::IDT Id
,
33 ArrayRef
<BPFunctionNode::UtilityNodeT
> UNs
) {
34 return AllOf(Field("Id", &BPFunctionNode::Id
, Id
),
35 Field("UtilityNodes", &BPFunctionNode::UtilityNodes
,
36 UnorderedElementsAreArray(UNs
)));
40 UnorderedElementsAre(NodeIs(0, {0, 1, 2}), NodeIs(1, {1, 2}),
41 NodeIs(2, {1, 2, 4, 5}), NodeIs(3, {2}),
42 NodeIs(4, {2, 3, 4, 5})));
45 } // end namespace llvm