ring::test

Struct TestCase

Source
pub struct TestCase { /* private fields */ }
Expand description

A test case. A test case consists of a set of named attributes. Every attribute in the test case must be consumed exactly once; this helps catch typos and omissions.

Requires the alloc default feature to be enabled.

Implementations§

Source§

impl TestCase

Source

pub fn consume_bool(&mut self, key: &str) -> bool

Maps the string “true” to true and the string “false” to false.

Source

pub fn consume_digest_alg(&mut self, key: &str) -> Option<&'static Algorithm>

Maps the strings “SHA1”, “SHA256”, “SHA384”, and “SHA512” to digest algorithms, maps “SHA224” to None, and panics on other (erroneous) inputs. “SHA224” is mapped to None because ring intentionally does not support SHA224, but we need to consume test vectors from NIST that have SHA224 vectors in them.

Source

pub fn consume_bytes(&mut self, key: &str) -> Vec<u8>

Returns the value of an attribute that is encoded as a sequence of an even number of hex digits, or as a double-quoted UTF-8 string. The empty (zero-length) value is represented as “”.

Source

pub fn consume_optional_bytes(&mut self, key: &str) -> Option<Vec<u8>>

Like consume_bytes() except it returns None if the test case doesn’t have the attribute.

Source

pub fn consume_usize(&mut self, key: &str) -> usize

Returns the value of an attribute that is an integer, in decimal notation.

Source

pub fn consume_usize_bits(&mut self, key: &str) -> BitLength

Returns the value of an attribute that is an integer, in decimal notation, as a bit length.

Source

pub fn consume_string(&mut self, key: &str) -> String

Returns the raw value of an attribute, without any unquoting or other interpretation.

Source

pub fn consume_optional_string(&mut self, key: &str) -> Option<String>

Like consume_string() except it returns None if the test case doesn’t have the attribute.

Trait Implementations§

Source§

impl Debug for TestCase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 24 bytes