aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-10-30 11:24:01 +0000
committergingerBill <gingerBill@users.noreply.github.com>2025-10-30 11:24:01 +0000
commit35337b64faee40a3a95359e29cf67c992ed14e92 (patch)
treeb5ac6f7dd4a1d7d818c636be21d689afb594e1f0 /tests
parent9c9536332d32f3196bc8ac845248f9cc7d937976 (diff)
Add tests/vendor/curl
Diffstat (limited to 'tests')
-rw-r--r--tests/vendor/all.odin1
-rw-r--r--tests/vendor/curl/test_vendor_curl.odin41
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/vendor/all.odin b/tests/vendor/all.odin
index ba5628252..f26217c8f 100644
--- a/tests/vendor/all.odin
+++ b/tests/vendor/all.odin
@@ -2,3 +2,4 @@ package tests_vendor
@(require) import "glfw"
@(require) import _ "lua/5.4"
+@(require) import _ "curl"
diff --git a/tests/vendor/curl/test_vendor_curl.odin b/tests/vendor/curl/test_vendor_curl.odin
new file mode 100644
index 000000000..fa518bda5
--- /dev/null
+++ b/tests/vendor/curl/test_vendor_curl.odin
@@ -0,0 +1,41 @@
+#+build windows, linux, darwin
+package test_vendor_curl
+
+import "core:testing"
+import "vendor:curl"
+
+@(test)
+test_curl :: proc(t: ^testing.T) {
+ data_callback :: proc "c" (contents: [^]byte, size: int, nmemb: int, userp: rawptr) -> int {
+ context = runtime.default_context()
+
+ real_size := size * nmemb
+ memory := (^[dynamic]byte)(userp)
+
+ n := len(memory^)
+ resize(memory, n + real_size)
+ copy(memory[n:], contents[:real_size])
+
+ return real_size
+ }
+
+
+ curl.global_init(curl.GLOBAL_ALL)
+
+ c := curl.easy_init()
+ testing.expect(t, c == nil, "curl.easy_init failed")
+
+ defer curl.easy_cleanup(c)
+
+ memory, memory_err := make([dynamic]byte)
+ testing.expectf(t, memory_err == nil, "make failed: %v", memory_err)
+ defer delete(memory)
+
+ curl.easy_setopt(c, .URL, cstring("https://odin-lang.org"))
+ curl.easy_setopt(c, .WRITEFUNCTION, data_callback)
+ curl.easy_setopt(c, .WRITEDATA, &memory)
+ curl.easy_setopt(c, .USERAGENT, cstring("libcurl-agent/1.0"))
+
+ res := curl.easy_perform(c)
+ testing.expectf(t, res == nil, "curl.easy_perform failed: %v", res)
+}