MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_decimal_decoding_fixed256

Function test_decimal_decoding_fixed256

arrow-avro/src/reader/record.rs:3522–3546  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3520
3521 #[test]
3522 fn test_decimal_decoding_fixed256() {
3523 let dt = avro_from_codec(Codec::Decimal(50, Some(2), Some(32)));
3524 let mut decoder = Decoder::try_new(&dt).unwrap();
3525 let row1 = [
3526 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3527 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3528 0x00, 0x00, 0x30, 0x39,
3529 ];
3530 let row2 = [
3531 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
3532 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
3533 0xFF, 0xFF, 0xFF, 0x85,
3534 ];
3535 let mut data = Vec::new();
3536 data.extend_from_slice(&row1);
3537 data.extend_from_slice(&row2);
3538 let mut cursor = AvroCursor::new(&data);
3539 decoder.decode(&mut cursor).unwrap();
3540 decoder.decode(&mut cursor).unwrap();
3541 let arr = decoder.flush(None).unwrap();
3542 let dec = arr.as_any().downcast_ref::<Decimal256Array>().unwrap();
3543 assert_eq!(dec.len(), 2);
3544 assert_eq!(dec.value_as_string(0), "123.45");
3545 assert_eq!(dec.value_as_string(1), "-1.23");
3546 }
3547
3548 #[test]
3549 fn test_decimal_decoding_fixed128() {

Callers

nothing calls this directly

Calls 7

avro_from_codecFunction · 0.85
try_newFunction · 0.85
extend_from_sliceMethod · 0.80
DecimalClass · 0.50
decodeMethod · 0.45
flushMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected