nanosvg_test.odin (1015B)
1 package nanosvg 2 3 import "core:fmt" 4 import "core:log" 5 import "core:os/os2" 6 import "core:strings" 7 import "core:testing" 8 9 // Smoke test to ensure we can parse from file and iterate the shapes. 10 @(test) 11 test_call_parse_from_file :: proc(t: ^testing.T) { 12 img := ParseFromFile("example/sample.svg", "px", 96) 13 defer Delete(img) 14 15 log.debugf("img: %v", img) 16 17 for shape := img.shapes; shape != nil; shape = shape.next { 18 log.debugf("shape: %v", shape) 19 } 20 } 21 22 // Smoke test to ensure we can parse from memory and iterate the shapes. 23 @(test) 24 test_call_parse_from_memory :: proc(t: ^testing.T) { 25 context.allocator = context.temp_allocator 26 defer free_all() 27 28 data, data_err := os2.read_entire_file_from_path("example/sample.svg", context.temp_allocator) 29 testing.expect(t, data_err == nil, "reading svg file") 30 31 img := Parse(strings.clone_to_cstring(string(data)), "px", 96) 32 defer Delete(img) 33 34 log.debugf("img: %v", img) 35 36 for shape := img.shapes; shape != nil; shape = shape.next { 37 log.debugf("shape: %v", shape) 38 } 39 } 40