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
5export component TestCase {
6 in-out property<string> p1: "hello";
7 in-out property<string> p2: "fox:🦊";
8 in-out property<string> p3: "with\"quote\\\"\u{8}";
9 in-out property<bool> e1: p2 == "fox:🦊";
10 in-out property<bool> e2: p2 == "fox:🦍";
11
12 // conversion from float
13 in property<float> value: 98.7654321;
14 out property <string> converted_value: round(value * 100)/100;
15 out property <bool> test: e1 && !e2 && converted_value == "98.77";
16}
17
18
19/*
20
21```cpp
22auto handle = TestCase::create();
23const TestCase &instance = *handle;
24assert_eq(instance.get_p1(), "hello");
25assert_eq(instance.get_p2(), "fox:🦊");
26assert_eq(instance.get_p3(), "with\"quote\\\"\x08");
27assert(instance.get_e1());
28assert(!instance.get_e2());
29assert(instance.get_test());
30```
31
32```rust
33let instance = TestCase::new().unwrap();
34assert_eq!(instance.get_p1(), "hello");
35assert_eq!(instance.get_p2(), "fox:🦊");
36assert_eq!(instance.get_p3(), "with\"quote\\\"\u{8}");
37assert!(instance.get_e1());
38assert!(!instance.get_e2());
39assert!(instance.get_test());
40```
41
42```js
43var instance = new slint.TestCase({});
44assert.equal(instance.p1, "hello");
45assert.equal(instance.p2, "fox:🦊");
46assert.equal(instance.p3, "with\"quote\\\"\u0008");
47assert(instance.e1);
48assert(!instance.e2);
49assert(instance.test);
50```
51
52*/
53}
54
55#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
56 use i_slint_backend_testing as slint_testing;
57 slint_testing::init();
58 let instance = TestCase::new().unwrap();
59 assert_eq!(instance.get_p1(), "hello");
60 assert_eq!(instance.get_p2(), "fox:🦊");
61 assert_eq!(instance.get_p3(), "with\"quote\\\"\u{8}");
62 assert!(instance.get_e1());
63 assert!(!instance.get_e2());
64 assert!(instance.get_test());
65 Ok(())
66}