Skip to content

Commit

Permalink
Add Gut testing framework, basic unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Sep 11, 2024
1 parent a296080 commit 0da4bea
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/godotengine/godot-cpp.git
[submodule "ext/Gut"]
path = ext/Gut
url = https://github.com/bitwes/Gut.git
1 change: 1 addition & 0 deletions ext/Gut
Submodule Gut added at a55b6c
1 change: 1 addition & 0 deletions tests/addons/gut
1 change: 1 addition & 0 deletions tests/extensions/bin/libgodot-riscv.linux.debug.x86_64.so
18 changes: 18 additions & 0 deletions tests/extensions/libgodot-riscv.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[configuration]

entry_symbol = "riscv_library_init"
compatibility_minimum = "4.1"

[icons]


[libraries]

macos.debug = "bin/libgodot-riscv.macos.debug.framework"
macos.release = "bin/libgodot-riscv.macos.release.framework"
windows.debug.x86_64 = "bin/libgodot-riscv.windows.debug.x86_64.dll"
windows.release.x86_64 = "bin/libgodot-riscv.windows.release.x86_64.dll"
linux.debug.x86_64 = "bin/libgodot-riscv.linux.debug.x86_64.so"
linux.release.x86_64 = "bin/libgodot-riscv.linux.release.x86_64.so"
web.debug.wasm32 = "bin/libgodot_riscv.web.template_debug.wasm32.wasm"
web.release.wasm32 = "bin/libgodot_riscv.web.template_release.wasm32.wasm"
1 change: 1 addition & 0 deletions tests/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions tests/icon.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://6xqmeymr5t3"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
19 changes: 19 additions & 0 deletions tests/project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=5

[application]

config/name="tests"
config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg"

[editor_plugins]

enabled=PackedStringArray("res://addons/gut/plugin.cfg")
9 changes: 9 additions & 0 deletions tests/tests/test_basic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "api.hpp"

extern "C" Variant public_function() {
return "Hello from the other side";
}

extern "C" Variant test_dictionary(Variant dict) {
return Dictionary(dict)["1"];
}
17 changes: 17 additions & 0 deletions tests/tests/test_basic.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
extends GutTest

func test_instantiation():
# Create a new sandbox
var s = Sandbox.new()
# Set the test program
s.set_program(Sandbox_TestsTests)

# Verify that a basic function that returns a String works
assert_eq(s.vmcall("public_function"), "Hello from the other side")

# Verify that the sandbox can receive a Dictionary and return an element
var d : Dictionary
d["1"] = Dictionary()
d["1"]["2"] = "3"

assert_eq(s.vmcall("test_dictionary", d), d["1"])

0 comments on commit 0da4bea

Please sign in to comment.