TEST_F(StructTypesSorterTests, ThreeStructTypesWithDependenciesAreProperlySorted) { // Input: // // struct C {}; // struct B { struct C c; }; // struct A { struct B b; }; // StructTypeSet structTypes; ShPtr<StructType> structC(StructType::create(StructType::ElementTypes(), "C")); structTypes.insert(structC); StructType::ElementTypes structBElements; structBElements.push_back(structC); ShPtr<StructType> structB(StructType::create(structBElements, "B")); structTypes.insert(structB); StructType::ElementTypes structAElements; structAElements.push_back(structB); ShPtr<StructType> structA(StructType::create(structAElements, "A")); structTypes.insert(structA); // Expected output: // // struct C {}; // struct B { struct C c; }; // struct A { struct B b; }; // StructTypeVector refSortedStructTypes; refSortedStructTypes.push_back(structC); refSortedStructTypes.push_back(structB); refSortedStructTypes.push_back(structA); EXPECT_EQ(refSortedStructTypes, StructTypesSorter::sort(structTypes)); }
TEST_F(StructTypesSorterTests, SingleStructTypeIsConvertedToSingletonVector) { // Input: // // struct A {}; // StructTypeSet structTypes; ShPtr<StructType> structA(StructType::create(StructType::ElementTypes(), "A")); structTypes.insert(structA); // Expected output: // // struct A {}; // StructTypeVector refSortedStructTypes; refSortedStructTypes.push_back(structA); EXPECT_EQ(refSortedStructTypes, StructTypesSorter::sort(structTypes)); }
structA max_value() const { return structA(std::numeric_limits<int>::max(), std::numeric_limits<int>::max()); }