@@ -247,3 +247,59 @@ impl fmt::Display for MetadataVersion {
247
247
write ! ( f, "{}" , self . as_str( ) )
248
248
}
249
249
}
250
+
251
+ #[ cfg( test) ]
252
+ mod tests {
253
+ use super :: * ;
254
+
255
+ #[ test]
256
+ fn serialize_default ( ) {
257
+ let settings = Settings :: default ( ) ;
258
+ let toml = settings. stringify ( ) ;
259
+ assert_eq ! (
260
+ toml,
261
+ r#"version = "12"
262
+
263
+ [overrides]
264
+ "#
265
+ ) ;
266
+ }
267
+
268
+ #[ test]
269
+ fn deserialize_default ( ) {
270
+ let toml = r#"version = "12""# ;
271
+ let settings = Settings :: parse ( toml) . unwrap ( ) ;
272
+ assert_eq ! ( settings. version, MetadataVersion :: V12 ) ;
273
+ }
274
+
275
+ #[ test]
276
+ fn serialize_basic ( ) {
277
+ let settings = Settings {
278
+ version : MetadataVersion :: V12 ,
279
+ default_toolchain : Some ( "stable-aarch64-apple-darwin" . to_owned ( ) ) ,
280
+ profile : Some ( Profile :: Default ) ,
281
+ ..Default :: default ( )
282
+ } ;
283
+
284
+ let toml = settings. stringify ( ) ;
285
+ assert_eq ! ( toml, BASIC , ) ;
286
+ }
287
+
288
+ #[ test]
289
+ fn deserialize_basic ( ) {
290
+ let settings = Settings :: parse ( BASIC ) . unwrap ( ) ;
291
+ assert_eq ! ( settings. version, MetadataVersion :: V12 ) ;
292
+ assert_eq ! (
293
+ settings. default_toolchain,
294
+ Some ( "stable-aarch64-apple-darwin" . to_owned( ) )
295
+ ) ;
296
+ assert_eq ! ( settings. profile, Some ( Profile :: Default ) ) ;
297
+ }
298
+
299
+ const BASIC : & str = r#"default_toolchain = "stable-aarch64-apple-darwin"
300
+ profile = "default"
301
+ version = "12"
302
+
303
+ [overrides]
304
+ "# ;
305
+ }
0 commit comments