Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Nov 18, 2024
1 parent 482c45c commit 87e3552
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vlib/json/tests/json_decode_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ struct DbConfig {

fn test_decode_error_message_should_have_enough_context_empty() {
json.decode(DbConfig, '') or {
assert err.msg().len < 2
assert err.msg() == 'failed to decode JSON string'
return
}
assert false
}

fn test_decode_error_message_should_have_enough_context_just_brace() {
json.decode(DbConfig, '{') or {
assert err.msg() == '{'
assert err.msg() == 'failed to decode JSON string: {'
return
}
assert false
Expand All @@ -111,7 +111,7 @@ fn test_decode_error_message_should_have_enough_context_trailing_comma_at_end()
"user": "alex",
}'
json.decode(DbConfig, txt) or {
assert err.msg() == ' "user": "alex",\n}'
assert err.msg().contains(' "user": "alex",\n}')
return
}
assert false
Expand All @@ -120,7 +120,7 @@ fn test_decode_error_message_should_have_enough_context_trailing_comma_at_end()
fn test_decode_error_message_should_have_enough_context_in_the_middle() {
txt := '{"host": "localhost", "dbname": "alex" "user": "alex", "port": "1234"}'
json.decode(DbConfig, txt) or {
assert err.msg() == 'ost", "dbname": "alex" "user":'
assert err.msg().contains('ost", "dbname": "alex" "user":')
return
}
assert false
Expand Down

0 comments on commit 87e3552

Please sign in to comment.