MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_enum_default

Function test_enum_default

src/avro/src/lib.rs:373–422  ·  view source on GitHub ↗

unsupported operation: inline assembly is not supported

()

Source from the content-addressed store, hash-verified

371 #[mz_ore::test]
372 #[cfg_attr(miri, ignore)] // unsupported operation: inline assembly is not supported
373 fn test_enum_default() {
374 let writer_raw_schema = r#"
375 {
376 "type": "record",
377 "name": "test",
378 "fields": [
379 {"name": "a", "type": "long", "default": 42},
380 {"name": "b", "type": "string"}
381 ]
382 }
383 "#;
384 let reader_raw_schema = r#"
385 {
386 "type": "record",
387 "name": "test",
388 "fields": [
389 {"name": "a", "type": "long", "default": 42},
390 {"name": "b", "type": "string"},
391 {
392 "name": "c",
393 "type": {
394 "type": "enum",
395 "name": "suit",
396 "symbols": ["diamonds", "spades", "clubs", "hearts"]
397 },
398 "default": "spades"
399 }
400 ]
401 }
402 "#;
403 let writer_schema = Schema::from_str(writer_raw_schema).unwrap();
404 let reader_schema = Schema::from_str(reader_raw_schema).unwrap();
405 let mut writer = Writer::with_codec(writer_schema.clone(), Vec::new(), Codec::Null);
406 let mut record = Record::new(writer_schema.top_node()).unwrap();
407 record.put("a", 27i64);
408 record.put("b", "foo");
409 writer.append(record).unwrap();
410 writer.flush().unwrap();
411 let input = writer.into_inner();
412 let mut reader = Reader::with_schema(&reader_schema, &input[..]).unwrap();
413 assert_eq!(
414 reader.next().unwrap().unwrap(),
415 Value::Record(vec![
416 ("a".to_string(), Value::Long(27)),
417 ("b".to_string(), Value::String("foo".to_string())),
418 ("c".to_string(), Value::Enum(1, "spades".to_string())),
419 ])
420 );
421 assert_none!(reader.next());
422 }
423
424 //TODO: move where it fits better
425 #[mz_ore::test]

Callers

nothing calls this directly

Calls 7

unwrapMethod · 0.80
top_nodeMethod · 0.80
putMethod · 0.80
cloneMethod · 0.45
appendMethod · 0.45
flushMethod · 0.45
into_innerMethod · 0.45

Tested by

no test coverage detected