1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/expr"# ] |
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 | |
5 | TestCase := Rectangle { |
6 | property<int> t1: floor(42.2); |
7 | property<int> t2: floor(23.5); |
8 | property<int> t3: floor(24.6); |
9 | property<int> t4: floor(25); |
10 | |
11 | property<int> n1: floor(-42.2); |
12 | property<int> n2: floor(-23.5); |
13 | property<int> n3: floor(-24.6); |
14 | property<int> n4: floor(-25); |
15 | } |
16 | /* |
17 | ```cpp |
18 | auto handle = TestCase::create(); |
19 | const TestCase &instance = *handle; |
20 | assert_eq(instance.get_t1(), 42); |
21 | assert_eq(instance.get_t2(), 23); |
22 | assert_eq(instance.get_t3(), 24); |
23 | assert_eq(instance.get_t4(), 25); |
24 | assert_eq(instance.get_n1(), -43); |
25 | assert_eq(instance.get_n2(), -24); |
26 | assert_eq(instance.get_n3(), -25); |
27 | assert_eq(instance.get_n4(), -25); |
28 | ``` |
29 | |
30 | ```rust |
31 | let instance = TestCase::new().unwrap(); |
32 | assert_eq!(instance.get_t1(), 42); |
33 | assert_eq!(instance.get_t2(), 23); |
34 | assert_eq!(instance.get_t3(), 24); |
35 | assert_eq!(instance.get_t4(), 25); |
36 | assert_eq!(instance.get_n1(), -43); |
37 | assert_eq!(instance.get_n2(), -24); |
38 | assert_eq!(instance.get_n3(), -25); |
39 | assert_eq!(instance.get_n4(), -25); |
40 | ``` |
41 | |
42 | ```js |
43 | var instance = new slint.TestCase({}); |
44 | assert.equal(instance.t1, 42); |
45 | assert.equal(instance.t2, 23); |
46 | assert.equal(instance.t3, 24); |
47 | assert.equal(instance.t4, 25); |
48 | assert.equal(instance.n1, -43); |
49 | assert.equal(instance.n2, -24); |
50 | assert.equal(instance.n3, -25); |
51 | assert.equal(instance.n4, -25); |
52 | ``` |
53 | */ |
54 | } |
55 | |
56 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
57 | use i_slint_backend_testing as slint_testing; |
58 | slint_testing::init(); |
59 | let instance = TestCase::new().unwrap(); |
60 | assert_eq!(instance.get_t1(), 42); |
61 | assert_eq!(instance.get_t2(), 23); |
62 | assert_eq!(instance.get_t3(), 24); |
63 | assert_eq!(instance.get_t4(), 25); |
64 | assert_eq!(instance.get_n1(), -43); |
65 | assert_eq!(instance.get_n2(), -24); |
66 | assert_eq!(instance.get_n3(), -25); |
67 | assert_eq!(instance.get_n4(), -25); |
68 | Ok(()) |
69 | } |