libcyaml
libcyaml copied to clipboard
Add test for optional boolean
I couldn't trivially tell if the default for boolean should be true or false, figured there should be a test for it. (Especially since it seems inverted looking at cyaml__read_bool)
Codecov Report
Merging #184 (cf5495f) into main (5b99bd9) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## main #184 +/- ##
=======================================
Coverage 97.14% 97.14%
=======================================
Files 9 9
Lines 1609 1609
Branches 347 347
=======================================
Hits 1563 1563
Misses 24 24
Partials 22 22
Flag | Coverage Δ | |
---|---|---|
unittests | 97.14% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more
cyaml__read_bool
isn't called unless there is an actual value in the YAML to decode.
The bit representation for any unset optional field is always 0
. So for numbers it's zero, pointer are NULL and a character string is the empty string "\0". For a boolean it is false
.
cyaml__read_bool
isn't called unless there is an actual value in the YAML to decode.The bit representation for any unset optional field is always
0
. So for numbers it's zero, pointer are NULL and a character string is the empty string "\0". For a boolean it isfalse
.
Yeah, I understand why that is, but when I first looked to see the answer it seemed like cyaml__read_bool
would be relevant. Either way it's reasonable to test it (maybe one day in the future it'll rightly fail on some futuristic platform where (int)true
is 0 :smile:).