Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/tokio/tests/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  io_util_empty.rs

  Sprache: Rust
 

#![cfg(feature = "full")]
use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncSeekExt};

#[tokio::test]
async fn empty_read_is_cooperative() {
    tokio::select! {
        biased;

        _ = async {
            loop {
                let mut buf = [0u8; 4096];
                let _ = tokio::io::empty().read(&mut buf).await;
            }
        } => {},
        _ = tokio::task::yield_now() => {}
    }
}

#[tokio::test]
async fn empty_buf_reads_are_cooperative() {
    tokio::select! {
        biased;

        _ = async {
            loop {
                let mut buf = String::new();
                let _ = tokio::io::empty().read_line(&mut buf).await;
            }
        } => {},
        _ = tokio::task::yield_now() => {}
    }
}

#[tokio::test]
async fn empty_seek() {
    use std::io::SeekFrom;

    let mut empty = tokio::io::empty();

    assert!(matches!(empty.seek(SeekFrom::Start(0)).await, Ok(0)));
    assert!(matches!(empty.seek(SeekFrom::Start(1)).await, Ok(0)));
    assert!(matches!(empty.seek(SeekFrom::Start(u64::MAX)).await, Ok(0)));

    assert!(matches!(empty.seek(SeekFrom::End(i64::MIN)).await, Ok(0)));
    assert!(matches!(empty.seek(SeekFrom::End(-1)).await, Ok(0)));
    assert!(matches!(empty.seek(SeekFrom::End(0)).await, Ok(0)));
    assert!(matches!(empty.seek(SeekFrom::End(1)).await, Ok(0)));
    assert!(matches!(empty.seek(SeekFrom::End(i64::MAX)).await, Ok(0)));

    assert!(matches!(
        empty.seek(SeekFrom::Current(i64::MIN)).await,
        Ok(0)
    ));
    assert!(matches!(empty.seek(SeekFrom::Current(-1)).await, Ok(0)));
    assert!(matches!(empty.seek(SeekFrom::Current(0)).await, Ok(0)));
    assert!(matches!(empty.seek(SeekFrom::Current(1)).await, Ok(0)));
    assert!(matches!(
        empty.seek(SeekFrom::Current(i64::MAX)).await,
        Ok(0)
    ));
}

Messung V0.5 in Prozent
C=85 H=93 G=88

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-18) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.