Skip to content

Commit bbac220

Browse files
committed
Additional tests
Related to #188 as an overload of Context.CreateStructType was missed.
1 parent ae1300c commit bbac220

File tree

4 files changed

+23
-52
lines changed

4 files changed

+23
-52
lines changed

src/Ubiquity.NET.Llvm.Tests/DebugInfo/DebugStructTypeTests.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.VisualStudio.TestTools.UnitTesting;
1010

1111
using Ubiquity.NET.Llvm.DebugInfo;
12+
using Ubiquity.NET.Llvm.Types;
1213

1314
namespace Ubiquity.NET.Llvm.Tests.DebugInfo
1415
{
@@ -65,21 +66,34 @@ public void DebugStructType_constructing_empty_anonymous_struct_succeeds( )
6566
Assert.AreEqual( sourceName, structType.SourceName );
6667
}
6768

68-
#if NOT_YET_READY_GENERATED
6969
[TestMethod]
70-
public void SetBody_StateUnderTest_ExpectedBehavior( )
70+
public void SetBody_with_native_elements_succeeds( )
7171
{
72-
var debugStructType = new DebugStructType( TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO );
72+
using var context = new Context( );
73+
using var testModule = context.CreateBitcodeModule( "test" );
74+
75+
var file = testModule.DIBuilder.CreateFile( "test.foo" );
76+
uint line = 1234;
77+
string sourceName = string.Empty;
78+
string linkageName = string.Empty;
79+
80+
var debugStructType = new DebugStructType( testModule, linkageName, file, sourceName, file, line );
7381
bool packed = false;
74-
ITypeRef[ ] elements = null;
82+
var elements = new ITypeRef[] { context.Float128Type, context.Int32Type, context.Int64Type };
7583

7684
debugStructType.SetBody(
7785
packed,
7886
elements );
7987

80-
Assert.Inconclusive( );
88+
Assert.AreEqual( elements.Length, debugStructType.Members.Count );
89+
for(int i =0; i < elements.Length; ++i )
90+
{
91+
Assert.AreSame( elements[ i ], debugStructType.Members[ i ] );
92+
}
8193
}
8294

95+
#if NOT_YET_READY_GENERATED
96+
8397
[TestMethod]
8498
public void SetBody_StateUnderTest_ExpectedBehavior1( )
8599
{

src/Ubiquity.NET.Llvm/Context.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public Constant CreateNamedConstantStruct( IStructType type, IEnumerable<Constan
396396
}
397397

398398
/// <summary>Create an opaque structure type (e.g. a forward reference)</summary>
399-
/// <param name="name">Name of the type</param>
399+
/// <param name="name">Name of the type (use <see cref="string.Empty"/> for anonymous types)</param>
400400
/// <remarks>
401401
/// This method creates an opaque type. The <see cref="IStructType.SetBody(bool, ITypeRef[])"/>
402402
/// method provides a means to add a body, including indication of packed status, to an opaque
@@ -406,7 +406,7 @@ public Constant CreateNamedConstantStruct( IStructType type, IEnumerable<Constan
406406
/// <returns>New type</returns>
407407
public IStructType CreateStructType( string name )
408408
{
409-
name.ValidateNotNullOrWhiteSpace( nameof( name ) );
409+
name.ValidateNotNull( nameof( name ) );
410410
var handle = LLVMStructCreateNamed( ContextHandle, name );
411411
return TypeRef.FromHandle<IStructType>( handle.ThrowIfInvalid( ) )!;
412412
}

src/Ubiquity.NET.Llvm/IOperandCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public interface IOperandCollection<T>
3333
bool Contains( T item );
3434

3535
/// <summary>Creates a slice of the collection</summary>
36-
/// <param name="start">inclusive start index for the slice</param>
36+
/// <param name="start">Inclusive start index for the slice</param>
3737
/// <param name="end">Exclusive end index for the slice</param>
3838
/// <returns>Slice of the collection</returns>
39-
[SuppressMessage( "Naming", "CA1716:Identifiers should not match keywords", Justification = "Name is consistent with System.Range parameters" )]
39+
[SuppressMessage( "Naming", "CA1716:Identifiers should not match keywords", Justification = "Naming is consistent with System.Range parameters" )]
4040
IOperandCollection<T> Slice( int start, int end )
4141
{
4242
return new OperandCollectionSlice<T>( this, new Range( start, end ) );

src/Ubiquity.NET.Llvm/IOperandContainer.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)