Skip to content

Commit

Permalink
Add some basic script command unit tests for NVSE commands
Browse files Browse the repository at this point in the history
  • Loading branch information
korri123 committed Apr 23, 2022
1 parent cda2093 commit 1b2eade
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
41 changes: 41 additions & 0 deletions nvse/nvse/gr_UnitTests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
array_var aVar = ar_list 1 2 3 4
Assert ((ar_Size aVar) == 4)

ar_append aVar 5
Assert ((ar_Size aVar) == 5)
Assert (aVar == (Ar_List 1 2 3 4 5))
Assert ((aVar[0]) == 1)
Assert ((aVar[4]) == 5)

ar_erase avar 0:5
Assert ((ar_Size aVar) == 0)
Assert !(testexpr aVar[0])
Assert !(testexpr aVar[4])

aVar = ar_list 1 2 3
ar_erase avar 0
Assert (aVar == (ar_list 2 3))

ar_resize avar 1
Assert (avar == (ar_list 2))

ar_insertRange avar 0 (ar_list 0 1)
Assert (avar == (ar_list 0 1 2))

CallAfter 0 (begin function {int iArg, float fArg, string_var sArg, array_var aArg}
Assert iArg == 10
Assert fArg == 5.5
Assert sArg == "Hello World"
Assert aArg == (ar_list 1 5 10)
end) 1 10 5.5 "Hello World" (ar_list 1 5 10)

ref TestUdfScript = (begin function {int iArg0, float fArg0, string_var sArg0, array_var aArg0}
Assert iArg0 == 2
Assert fArg0 == 3.5
Assert sArg0 == "Jingle Bells"
Assert aArg0 == (ar_map "Key"::"Value")
end)

call TestUdfScript 2 3.5 "Jingle Bells" (ar_map "Key"::"Value")

print "Finished running xNVSE script unit tests"
7 changes: 6 additions & 1 deletion nvse/nvse/nvse.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@
</Link>
<PostBuildEvent>
<Message>Installing DLL...</Message>
<Command>copy "$(TargetPath)" "$(FalloutNVPath)\nvse_1_4.dll"</Command>
<Command>copy "$(TargetPath)" "$(FalloutNVPath)\nvse_1_4.dll"
copy "$(ProjectDir)gr_UnitTests.txt" "$(FalloutNVPath)\Data\NVSE\Plugins\scripts\gr_UnitTests.txt"
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down Expand Up @@ -757,6 +759,9 @@
<ItemGroup>
<Natvis Include="DebuggerVisualizations.natvis" />
</ItemGroup>
<ItemGroup>
<Text Include="gr_UnitTests.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
3 changes: 3 additions & 0 deletions nvse/nvse/nvse.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,7 @@
<ItemGroup>
<Natvis Include="DebuggerVisualizations.natvis" />
</ItemGroup>
<ItemGroup>
<Text Include="gr_UnitTests.txt" />
</ItemGroup>
</Project>

0 comments on commit 1b2eade

Please sign in to comment.