Browse Source

Used `strings.builder_reset` instead of `clear` for the string builder

Hector 1 year ago
parent
commit
82088e4a75
1 changed files with 6 additions and 4 deletions
  1. 6 4
      tests/core/slice/test_core_slice.odin

+ 6 - 4
tests/core/slice/test_core_slice.odin

@@ -185,20 +185,22 @@ test_sort_by_indices :: proc(t: ^testing.T) {
 
 @test
 test_binary_search :: proc(t: ^testing.T) {
-	index: int
-	found: bool
 	builder := strings.Builder{}
+	defer strings.builder_destroy(&builder)
 
 	test_search :: proc(t: ^testing.T, b: ^strings.Builder, s: []i32, v: i32) -> (int, bool) {
 		log(t, fmt.sbprintf(b, "Searching for %v in %v", v, s))
-		clear(&b.buf)
+		strings.builder_reset(b)
 		index, found := slice.binary_search(s, v)
 		log(t, fmt.sbprintf(b, "index: %v, found: %v", index, found))
-		clear(&b.buf)
+		strings.builder_reset(b	)
 
 		return index, found
 	}
 
+	index: int
+	found: bool
+
 	s := []i32{0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55}
 
 	index, found = test_search(t, &builder, s, 13)