Skip to content

Commit c9b481c

Browse files
committed
test(toml): Ensure tables are used for validation
1 parent 43d7f29 commit c9b481c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

crates/toml/tests/decoder.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ impl toml_test_harness::Decoder for Decoder {
1111
fn decode(&self, data: &[u8]) -> Result<toml_test_harness::Decoded, toml_test_harness::Error> {
1212
let data = std::str::from_utf8(data).map_err(toml_test_harness::Error::new)?;
1313
let document = data
14-
.parse::<toml::Value>()
14+
.parse::<toml::Table>()
1515
.map_err(toml_test_harness::Error::new)?;
16-
value_to_decoded(&document)
16+
let value = toml::Value::Table(document);
17+
value_to_decoded(&value)
1718
}
1819
}
1920

crates/toml/tests/encoder.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ impl toml_test_harness::Encoder for Encoder {
1010

1111
fn encode(&self, data: toml_test_harness::Decoded) -> Result<String, toml_test_harness::Error> {
1212
let value = from_decoded(&data)?;
13-
let s = toml::to_string(&value).map_err(toml_test_harness::Error::new)?;
13+
let toml::Value::Table(document) = value else {
14+
return Err(toml_test_harness::Error::new("no root table"));
15+
};
16+
let s = toml::to_string(&document).map_err(toml_test_harness::Error::new)?;
1417
Ok(s)
1518
}
1619
}

0 commit comments

Comments
 (0)