ki18n-rs/tests/klocalizedcontext_tests.rs
Ayush Singh 38ebb314b8 Refactored KLocalizedContext
Extracted everything from lib.rs
Also extracted all doc tests to integration tests.
2021-12-01 17:34:45 +05:30

38 lines
893 B
Rust

use ki18n_rs::KLocalizedContext;
use qmetaobject::prelude::*;
mod common;
#[test]
fn init_engine() {
let _lock = common::lock_for_test();
let engine = QmlEngine::new();
KLocalizedContext::init_from_engine(&engine);
}
#[test]
fn cpp_ptr() {
let _lock = common::lock_for_test();
let engine = QmlEngine::new();
let context = KLocalizedContext::init_from_engine(&engine);
let context_ptr = context.cpp_ptr();
assert_ne!(std::ptr::null(), context_ptr);
}
#[test]
fn translation_domain() {
let _lock = common::lock_for_test();
let engine = QmlEngine::new();
let mut context = KLocalizedContext::init_from_engine(&engine);
const TRANSLATION_DOMAIN: &str = "Test Domain";
context.set_translation_domain(TRANSLATION_DOMAIN.into());
let domain = context.translation_domain();
assert_eq!(domain, QString::from(TRANSLATION_DOMAIN));
}