1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/types"#]
2// Copyright © SixtyFPS GmbH <info@slint.dev>
3// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
4
5TestCase := Rectangle {
6 property<float> p1: 100%;
7 property<float> p2: 1%;
8 property<float> p3: 5.5%;
9 property<float> p4: 10 + 50%;
10}
11
12
13/*
14
15```cpp
16auto handle = TestCase::create();
17const TestCase &instance = *handle;
18auto fuzzy_compare = [](float a, float b) { return std::abs(a - b) < 0.00000001; };
19assert(fuzzy_compare(instance.get_p1(), 1.));
20assert(fuzzy_compare(instance.get_p2(), 0.01));
21assert(fuzzy_compare(instance.get_p3(), 0.055));
22assert(fuzzy_compare(instance.get_p4(), 10.5));
23// self_test
24assert(!fuzzy_compare(instance.get_p1(), 1.001));
25```
26
27```rust
28let instance = TestCase::new().unwrap();
29assert_eq!(instance.get_p1(), 1.);
30assert_eq!(instance.get_p2(), 0.01);
31assert_eq!(instance.get_p3(), 0.055);
32assert_eq!(instance.get_p4(), 10.5);
33
34assert_ne!(instance.get_p3(), 0.0549);
35```
36
37```js
38var instance = new slint.TestCase({});
39function n(a) { return Math.round(a*1000000) }
40assert.equal(n(instance.p1), n(1.));
41assert.equal(n(instance.p2), n(0.01));
42assert.equal(n(instance.p3), n(0.055));
43assert.equal(n(instance.p4), n(10.5));
44// self_test
45assert.notEqual(n(instance.p1), n(1.001));
46
47```
48
49*/
50}
51
52#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
53 use i_slint_backend_testing as slint_testing;
54 slint_testing::init();
55 let instance = TestCase::new().unwrap();
56 assert_eq!(instance.get_p1(), 1.);
57 assert_eq!(instance.get_p2(), 0.01);
58 assert_eq!(instance.get_p3(), 0.055);
59 assert_eq!(instance.get_p4(), 10.5);
60
61 assert_ne!(instance.get_p3(), 0.0549);
62 Ok(())
63}