Skip to content

Commit

Permalink
Merge pull request #4155 from Feoramund/fix-test-vet-style
Browse files Browse the repository at this point in the history
Fix `-vet` and `-strict-style` failures in tests
  • Loading branch information
laytan authored Aug 26, 2024
2 parents ef254ec + 1f04f54 commit 6c17642
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
24 changes: 12 additions & 12 deletions tests/core/c/libc/test_core_libc_complex_pow.odin
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ test_libc_pow_binding :: proc(t: ^testing.T, $LIBC_COMPLEX:typeid, $F:typeid, po
complex_power := LIBC_COMPLEX(complex(F(n), F(0.)))
result := pow(complex_base, complex_power)
switch n%%4 {
case 0:
expected_real = value
expected_imag = 0.
case 1:
expected_real = 0.
expected_imag = value
case 2:
expected_real = -value
expected_imag = 0.
case 3:
expected_real = 0.
expected_imag = -value
case 0:
expected_real = value
expected_imag = 0.
case 1:
expected_real = 0.
expected_imag = value
case 2:
expected_real = -value
expected_imag = 0.
case 3:
expected_real = 0.
expected_imag = -value
}
testing.expectf(t, isclose(t, expected_real, F(real(result)), rtol, atol), "ftype:%T, n:%v reldiff(%v, re(%v)) is greater than specified rtol:%e", F{}, n, expected_real, result, rtol)
testing.expectf(t, isclose(t, expected_imag, F(imag(result)), rtol, atol), "ftype:%T, n:%v reldiff(%v, im(%v)) is greater than specified rtol:%e", F{}, n, expected_imag, result, rtol)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/container/test_core_rbtree.odin
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ validate_rbtree :: proc(t: ^testing.T, tree: ^$T/rb.Tree($Key, $Value)) {
}

verify_rbtree_propery_1 :: proc(t: ^testing.T, n: ^$N/rb.Node($Key, $Value)) {
testing.expect(t, rb.node_color(n) == .Black || rb.node_color(n) == .Red, "Property #1: Each node is either red or black.")
testing.expect(t, rb.node_color(n) == .Black || rb.node_color(n) == .Red, "Property #1: Each node is either red or black.")
if n == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion tests/core/encoding/json/test_core_json.odin
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ map_with_integer_keys :: proc(t: ^testing.T) {
defer delete_map(my_map2)

unmarshal_err := json.unmarshal(marshaled_data, &my_map2)
defer for key, item in my_map2 {
defer for _, item in my_map2 {
runtime.delete_string(item)
}
testing.expectf(t, unmarshal_err == nil, "Expected `json.unmarshal` to return nil, got %v", unmarshal_err)
Expand Down
10 changes: 5 additions & 5 deletions tests/core/encoding/xml/test_core_xml.odin
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
written += fmt.wprintf(writer, "[DOCTYPE] %v\n", doc.doctype.ident)

if len(doc.doctype.rest) > 0 {
fmt.wprintf(writer, "\t%v\n", doc.doctype.rest)
fmt.wprintf(writer, "\t%v\n", doc.doctype.rest)
}
}

Expand All @@ -250,10 +250,10 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) {
}

if doc.element_count > 0 {
fmt.wprintln(writer, " --- ")
print_element(writer, doc, 0)
fmt.wprintln(writer, " --- ")
}
fmt.wprintln(writer, " --- ")
print_element(writer, doc, 0)
fmt.wprintln(writer, " --- ")
}

return written, .None
}
Expand Down
3 changes: 1 addition & 2 deletions tests/core/unicode/test_core_unicode.odin
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ run_test_cases :: proc(t: ^testing.T, test_cases: []Test_Case, loc := #caller_lo
result, _, _ := utf8.grapheme_count(c.str)
if !testing.expectf(t, result == c.expected_clusters,
"(#% 4i) graphemes: %i != %i, %q %s", i, result, c.expected_clusters, c.str, c.str,
loc = loc)
{
loc = loc) {
failed += 1
}
}
Expand Down

0 comments on commit 6c17642

Please sign in to comment.