Creating UDataTable object.

Hey,

I need to create UDataTable object (or something similar) to write tests on my function.

I want to create object and add few values depending on test I do. My RowBase is FMyKeywordRowBase given below.

/// Simple Test Example
UDataTable* data_table = {}; // make some DT
data_table // add new row

return call_my_function(data_table); // Returns true/false


/// RowBase for DataTable
USTRUCT(BlueprintType)
struct FMyKeywordRowBase : public FTableRowBase
{
public:
	GENERATED_BODY()

	/// UEnum
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyStruct")
	EN_KeywordsGroups Group;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyStruct")
	FString Keyword;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyStruct")
	FString Description;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyStruct")
	bool AddExplanation;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyStruct")
	FString OverrideWordHelper;

};
	UDataTable* data_table = NewObject<UDataTable>(); /// Define
	data_table->RowStruct = FMyKeywordRowBase::StaticStruct();

	FMyKeywordRowBase* temp_row = new FMyKeywordRowBase();
	temp_row->Group = EN_RichStyleTags::danger;
	temp_row->Keyword = "damage";
	temp_row->IncludeExplanation = EN_MyToolTipOccurances::Single;
	data_table->AddRow(TEXT("Row1"), *temp_row);

	temp_row->Keyword = "critical damage";
	data_table->AddRow(TEXT("Row2"), *temp_row);

	temp_row->Keyword = "danger";
	data_table->AddRow(TEXT("Row3"), *temp_row);

	temp_row->Keyword = "fire damage";
	data_table->AddRow(TEXT("Row4"), *temp_row);

	delete temp_row;

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.