Jlm
AttributeSetTests.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2024 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #include <gtest/gtest.h>
7 
9 #include <jlm/rvsdg/TestType.hpp>
10 
11 #include <cassert>
12 
13 TEST(AttributeSetTests, TestEquality)
14 {
15  using namespace jlm::llvm;
16 
17  // Arrange
18  auto valueType = jlm::rvsdg::TestType::createValueType();
19 
22 
23  IntAttribute intAttribute1(Attribute::kind::Alignment, 4);
24  IntAttribute intAttribute2(Attribute::kind::AllocSize, 8);
25 
26  StringAttribute stringAttribute1("myKind1", "myValue");
27  StringAttribute stringAttribute2("myKind2", "myValue");
28 
29  TypeAttribute typeAttribute1(Attribute::kind::ByRef, valueType);
30  TypeAttribute typeAttribute2(Attribute::kind::ByVal, valueType);
31 
32  AttributeSet set1;
33  set1.InsertEnumAttribute(enumAttribute1);
34  set1.InsertIntAttribute(intAttribute1);
35  set1.InsertStringAttribute(stringAttribute1);
36  set1.InsertTypeAttribute(typeAttribute1);
37 
38  AttributeSet set2;
39  set2.InsertEnumAttribute(enumAttribute2);
40  set2.InsertIntAttribute(intAttribute2);
41  set2.InsertStringAttribute(stringAttribute2);
42  set2.InsertTypeAttribute(typeAttribute2);
43 
44  AttributeSet set3;
45  set3.InsertEnumAttribute(enumAttribute1);
46  set3.InsertIntAttribute(intAttribute1);
47  set3.InsertStringAttribute(stringAttribute1);
48  set3.InsertTypeAttribute(typeAttribute1);
49 
50  // Act & Assert
51  EXPECT_EQ(set1, set1);
52  EXPECT_NE(set1, set2);
53  EXPECT_EQ(set1, set3);
54 
55  EXPECT_EQ(set2, set2);
56  EXPECT_NE(set2, set3);
57 
58  EXPECT_EQ(set3, set3);
59 }
TEST(AttributeSetTests, TestEquality)
void InsertTypeAttribute(const TypeAttribute &attribute)
Definition: attribute.hpp:344
void InsertStringAttribute(const StringAttribute &attribute)
Definition: attribute.hpp:350
void InsertEnumAttribute(const EnumAttribute &attribute)
Definition: attribute.hpp:332
void InsertIntAttribute(const IntAttribute &attribute)
Definition: attribute.hpp:338
Integer attribute.
Definition: attribute.hpp:201
String attribute.
Definition: attribute.hpp:145
static std::shared_ptr< const TestType > createValueType()
Definition: TestType.cpp:67
Global memory state passed between functions.