microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
billti/num2-sim

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/resource_estimator/src/system/serialization/tests.rs

23lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use super::parse_time_str_as_ns;
5
6#[test]
7fn test_time_parsing() {
8 assert_eq!(parse_time_str_as_ns("1 ns"), Some(1));
9 assert_eq!(parse_time_str_as_ns("1.0 ns"), Some(1));
10 assert_eq!(parse_time_str_as_ns("1.0 ns"), Some(1));
11 assert_eq!(parse_time_str_as_ns("1e0 ns"), Some(1));
12 assert_eq!(parse_time_str_as_ns("1e1 ns"), Some(10));
13 assert_eq!(parse_time_str_as_ns("1e-1 ns"), Some(0));
14 assert_eq!(parse_time_str_as_ns("+1e-1 ns"), Some(0));
15 assert!(parse_time_str_as_ns("-1e-1 ns").is_none());
16
17 assert_eq!(parse_time_str_as_ns("1 μs"), Some(1000));
18 assert_eq!(parse_time_str_as_ns("1 µs"), Some(1000));
19 assert_eq!(parse_time_str_as_ns("1 us"), Some(1000));
20 assert_eq!(parse_time_str_as_ns("1 \u{03bc}s"), Some(1000));
21 assert_eq!(parse_time_str_as_ns("1 ms"), Some(1_000_000));
22 assert_eq!(parse_time_str_as_ns("1 s"), Some(1_000_000_000));
23}
24