MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / test_prng_random_value

Function test_prng_random_value

ciphercore-base/src/random.rs:412–439  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

410
411 #[test]
412 fn test_prng_random_value() {
413 let mut g = PRNG::new(None).unwrap();
414 let mut helper = |t: Type| -> Result<()> {
415 let v = g.get_random_value(t.clone())?;
416 assert!(v.check_type(t)?);
417 Ok(())
418 };
419 || -> Result<()> {
420 helper(scalar_type(BIT))?;
421 helper(scalar_type(UINT8))?;
422 helper(scalar_type(INT32))?;
423 helper(array_type(vec![2, 5], BIT))?;
424 helper(array_type(vec![2, 5], UINT8))?;
425 helper(array_type(vec![2, 5], INT32))?;
426 helper(tuple_type(vec![scalar_type(BIT), scalar_type(INT32)]))?;
427 helper(tuple_type(vec![
428 vector_type(3, scalar_type(BIT)),
429 vector_type(5, scalar_type(BIT)),
430 scalar_type(BIT),
431 scalar_type(INT32),
432 ]))?;
433 helper(named_tuple_type(vec![
434 ("field 1".to_owned(), scalar_type(BIT)),
435 ("field 2".to_owned(), scalar_type(INT32)),
436 ]))
437 }()
438 .unwrap()
439 }
440 #[test]
441 fn test_prng_random_value_flush() {
442 let mut g = PRNG::new(None).unwrap();

Callers

nothing calls this directly

Calls 6

get_random_valueMethod · 0.80
cloneMethod · 0.80
scalar_typeFunction · 0.70
array_typeFunction · 0.70
tuple_typeFunction · 0.70
named_tuple_typeFunction · 0.70

Tested by

no test coverage detected