|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +using Microsoft.CodeAnalysis.CSharp.Syntax; |
| 5 | +using Silk.NET.SilkTouch.Symbols; |
| 6 | +using Xunit; |
| 7 | + |
| 8 | +namespace Silk.NET.SilkTouch.Emitter.Tests; |
| 9 | + |
| 10 | +public sealed class EmitterStructTests : EmitterTest |
| 11 | +{ |
| 12 | + [Fact] |
| 13 | + public void StructIsStructSyntax() |
| 14 | + { |
| 15 | + var syntax = Transform(new StructSymbol(new IdentifierSymbol("Test"))); |
| 16 | + Assert.IsType<StructDeclarationSyntax>(syntax); |
| 17 | + } |
| 18 | + |
| 19 | + [Fact] |
| 20 | + public void StructHasStructKeyword() |
| 21 | + { |
| 22 | + var syntax = Transform(new StructSymbol(new IdentifierSymbol("Test"))) as StructDeclarationSyntax; |
| 23 | + Assert.Equal("struct", syntax!.Keyword.Text); |
| 24 | + } |
| 25 | + |
| 26 | + [Fact] |
| 27 | + public void StructHasCorrectIdentifier() |
| 28 | + { |
| 29 | + var syntax = Transform(new StructSymbol(new IdentifierSymbol("Test"))) as StructDeclarationSyntax; |
| 30 | + Assert.Equal("Test", syntax!.Identifier.Text); |
| 31 | + } |
| 32 | + |
| 33 | + [Fact] |
| 34 | + public void StructIsOnlyPublic() |
| 35 | + { |
| 36 | + var syntax = Transform(new StructSymbol(new IdentifierSymbol("Test"))) as StructDeclarationSyntax; |
| 37 | + var @public = Assert.Single(syntax!.Modifiers); |
| 38 | + Assert.Equal("public", @public.Text); |
| 39 | + } |
| 40 | + |
| 41 | + [Fact] |
| 42 | + public void IntegrationEmptyStruct() |
| 43 | + { |
| 44 | + // Note that this test also covers trivia, which is not checked otherwise. |
| 45 | + Assert.Equal("public struct Test{}", Transform(new StructSymbol(new IdentifierSymbol("Test"))).ToFullString()); |
| 46 | + } |
| 47 | +} |
0 commit comments