Skip to content

Commit 131d994

Browse files
committed
Add uom test case provided by iliekturtles
1 parent 18d79cb commit 131d994

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

test_cases/Cargo.lock

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test_cases/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ edition = "2021"
99
trybuild = "1"
1010
diesel = {version = "2.0.0-rc.0", default-features = false, features = ["sqlite", "postgres", "mysql"]}
1111
chumsky = "0.8.0"
12+
uom = "0.33.0"

test_cases/tests/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ fn chumsky() {
1212
let t = trybuild::TestCases::new();
1313
t.compile_fail("tests/chumsky/*.rs");
1414
}
15+
16+
#[test]
17+
fn uom() {
18+
let t = trybuild::TestCases::new();
19+
t.compile_fail("tests/uom/*.rs");
20+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use uom::si::f32::*;
2+
use uom::si::length::meter;
3+
use uom::si::time::second;
4+
5+
fn main() {
6+
// Setup length and time quantities using different units.
7+
let l1 = Length::new::<meter>(15.0);
8+
let t1 = Time::new::<second>(50.0);
9+
let error = l1 + t1;
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error[E0308]: mismatched types
2+
--> tests/uom/type_missmatch.rs:9:22
3+
|
4+
9 | let error = l1 + t1;
5+
| ^^ expected struct `Z0`, found struct `PInt`
6+
|
7+
= note: expected struct `Quantity<dyn Dimension<N = Z0, M = Z0, J = Z0, Th = Z0, T = Z0, Kind = (dyn Kind + 'static), L = PInt<UInt<UTerm, B1>>, I = Z0>, _, _>`
8+
found struct `Quantity<dyn Dimension<N = Z0, M = Z0, J = Z0, Th = Z0, T = PInt<UInt<UTerm, B1>>, Kind = (dyn Kind + 'static), L = Z0, I = Z0>, dyn uom::si::Units<f32, electric_current = uom::si::electric_current::ampere, luminous_intensity = uom::si::luminous_intensity::candela, mass = uom::si::mass::kilogram, thermodynamic_temperature = uom::si::thermodynamic_temperature::kelvin, length = uom::si::length::meter, time = uom::si::time::second, amount_of_substance = uom::si::amount_of_substance::mole>, _>`

0 commit comments

Comments
 (0)