prelude_test.odin (1088B)
1 package prelude 2 3 import "core:mem" 4 import "core:os" 5 import "core:strings" 6 import "core:testing" 7 8 @(test) 9 failed_shapes :: proc(t: ^testing.T) { 10 testing.expect(t, !failed(os.Error(nil))) 11 testing.expect(t, failed(os.Error(os.General_Error.Not_Exist))) 12 testing.expect(t, !failed(mem.Allocator_Error.None)) 13 testing.expect(t, failed(mem.Allocator_Error.Out_Of_Memory)) 14 testing.expect(t, !failed("")) 15 testing.expect(t, failed("boom")) 16 p: ^int 17 testing.expect(t, !failed(p)) 18 } 19 20 @(test) 21 must_passes_values_through :: proc(t: ^testing.T) { 22 testing.expect_value(t, must(42, true), 42) 23 testing.expect_value(t, must("s", os.Error(nil)), "s") 24 must(true) 25 must(os.Error(nil)) 26 } 27 28 @(test) 29 logfmt_quoting :: proc(t: ^testing.T) { 30 b := strings.builder_make(context.temp_allocator) 31 write_quoted(&b, "say \"hi\"\n\\") 32 testing.expect_value(t, strings.to_string(b), `"say \"hi\"\n\\"`) 33 } 34 35 @(test) 36 env_default :: proc(t: ^testing.T) { 37 testing.expect_value(t, env("JM_PRELUDE_UNSET_3F9A", "fallback", context.temp_allocator), "fallback") 38 testing.expect_value(t, level_name(.Warning), "warning") 39 }