From: Lei Zhang Date: Fri, 26 Aug 2016 18:02:40 +0000 (-0400) Subject: Add tests for decoration_empty(). X-Git-Tag: upstream/2018.6~1095 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a175eb0d655c7e0ee3be18f85cd32c5ca4a68de;p=platform%2Fupstream%2FSPIRV-Tools.git Add tests for decoration_empty(). --- diff --git a/test/opt/test_type_manager.cpp b/test/opt/test_type_manager.cpp index fc9966f..f8e37f7 100644 --- a/test/opt/test_type_manager.cpp +++ b/test/opt/test_type_manager.cpp @@ -207,4 +207,35 @@ TEST(Struct, DecorationOnMember) { } } +TEST(Types, DecorationEmpty) { + const std::string text = R"( + OpDecorate %struct1 Block + OpMemberDecorate %struct2 0 Offset 0 + + %u32 = OpTypeInt 32 0 ; id: 3 + %f32 = OpTypeFloat 32 ; id: 4 + %struct1 = OpTypeStruct %u32 %f32 + %struct2 = OpTypeStruct %f32 %u32 + %struct5 = OpTypeStruct %f32 + )"; + std::unique_ptr module = + SpvTools(SPV_ENV_UNIVERSAL_1_1).BuildModule(text); + opt::analysis::TypeManager manager(*module); + + ASSERT_EQ(5u, manager.NumTypes()); + ASSERT_EQ(0u, manager.NumForwardPointers()); + // Make sure we get ids correct. + ASSERT_EQ("uint32", manager.GetType(3)->str()); + ASSERT_EQ("float32", manager.GetType(4)->str()); + + // %struct1 with decoration on itself + EXPECT_FALSE(manager.GetType(1)->decoration_empty()); + // %struct2 with decoration on its member + EXPECT_FALSE(manager.GetType(2)->decoration_empty()); + EXPECT_TRUE(manager.GetType(3)->decoration_empty()); + EXPECT_TRUE(manager.GetType(4)->decoration_empty()); + // %struct5 has no decorations + EXPECT_TRUE(manager.GetType(5)->decoration_empty()); +} + } // anonymous namespace