Add tests for `locale_select` backends on unix

finchie
Jun 27, 2024, 6:32 AM
JZXXFWQKOYAFQLQZDRALXG4KGEDR7JKO3AZ5Q5X7IQTS7BCJP3QAC

Dependencies

  • [2] WBI5HFOB Add simple wrapper for `libc::settext()` to query system locale
  • [*] UKFEFT6L Create basic `Output` proc-macro
  • [*] VNSHGQYN Support using glob paths in `localize` macro
  • [*] O77KA6C4 Create `fluent_embed` crate
  • [*] SHNZZSZG Create `cli_macros` shim crate
  • [*] HCGVXOF7 Add language negotiation using `fluent-langneg`
  • [*] YNEOCYMG Create `locale-select` crate

Change contents

  • edit in Cargo.lock at line 13
    [5.1230]
    [5.1230]
    [[package]]
    name = "block"
    version = "0.1.6"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
    [[package]]
    name = "cc"
    version = "1.0.101"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d"
  • edit in Cargo.lock at line 117
    [5.1960]
    [6.1986]
    ]
    [[package]]
    name = "gettext-rs"
    version = "0.7.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "e49ea8a8fad198aaa1f9655a2524b64b70eb06b2f3ff37da407566c93054f364"
    dependencies = [
    "gettext-sys",
    "locale_config",
    ]
    [[package]]
    name = "gettext-sys"
    version = "0.21.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "c63ce2e00f56a206778276704bbe38564c8695249fdc8f354b4ef71c57c3839d"
    dependencies = [
    "cc",
    "temp-dir",
  • edit in Cargo.lock at line 238
    [7.3670]
    [2.19]
    [[package]]
    name = "lazy_static"
    version = "1.5.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
  • edit in Cargo.lock at line 256
    [7.3861]
    [5.2186]
    [[package]]
    name = "locale_config"
    version = "0.3.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934"
    dependencies = [
    "lazy_static",
    "objc",
    "objc-foundation",
    "regex",
    "winapi",
    ]
  • edit in Cargo.lock at line 275
    [8.1931]
    [9.5715]
    "gettext-rs",
  • edit in Cargo.lock at line 277
    [9.5729]
    [2.210]
    "libc",
    ]
    [[package]]
    name = "malloc_buf"
    version = "0.0.6"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
    dependencies = [
  • edit in Cargo.lock at line 309
    [5.2810]
    [5.2810]
    ]
    [[package]]
    name = "objc"
    version = "0.2.7"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
    dependencies = [
    "malloc_buf",
    ]
    [[package]]
    name = "objc-foundation"
    version = "0.1.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
    dependencies = [
    "block",
    "objc",
    "objc_id",
    ]
    [[package]]
    name = "objc_id"
    version = "0.1.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
    dependencies = [
    "objc",
  • edit in Cargo.lock at line 477
    [6.2224]
    [6.2224]
    [[package]]
    name = "temp-dir"
    version = "0.1.13"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1f227968ec00f0e5322f9b8173c7a0cbcff6181a0a5b28e9892491c286277231"
  • edit in locale_select/tests/unix.rs at line 1
    [9.78]
    [9.79]
    use std::collections::HashSet;
    use gettextrs::LocaleCategory as GettextCategory;
    use locale_select::fetch::unix::LocaleCategory as LocaleSelectCategory;
  • edit in locale_select/tests/unix.rs at line 6
    [9.117]
    [9.117]
    const GETTEXT_CATEGORIES: [GettextCategory; 13] = [
    GettextCategory::LcAll,
    GettextCategory::LcCType,
    GettextCategory::LcCollate,
    GettextCategory::LcMessages,
    GettextCategory::LcMonetary,
    GettextCategory::LcNumeric,
    GettextCategory::LcTime,
    GettextCategory::LcAddress,
    GettextCategory::LcIdentification,
    GettextCategory::LcMeasurement,
    GettextCategory::LcName,
    GettextCategory::LcPaper,
    GettextCategory::LcTelephone,
    ];
  • edit in locale_select/tests/unix.rs at line 42
    [9.438]
    #[test]
    /// Exactly compare the output of get_locales_libc() with get_locales_custom()
    fn compare_libc_with_custom_impl_exact() {
    for gettext_category in GETTEXT_CATEGORIES {
    let locale_select_category =
    LocaleSelectCategory::try_from(gettext_category as i32).unwrap();
    let libc_locales = locale_select_category.get_locales_libc();
    let custom_locales = locale_select_category.get_locales_custom();
    assert_eq!(libc_locales, custom_locales);
    }
    }
    #[test]
    /// Compare the output of get_locales_libc() with get_locales_custom() using a HashSet
    ///
    /// This will make sure that both functions return the same data, even if it's not
    /// in the same order or items are duplicated. If the `_exact()` variant of this test
    /// fails, this test may still pass.
    fn compare_libc_with_custom_impl_hash_set() {
    for gettext_category in GETTEXT_CATEGORIES {
    let locale_select_category =
    LocaleSelectCategory::try_from(gettext_category as i32).unwrap();
    let libc_locales: HashSet<String> =
    HashSet::from_iter(locale_select_category.get_locales_libc().into_iter());
    let custom_locales: HashSet<String> =
    HashSet::from_iter(locale_select_category.get_locales_custom().into_iter());
    assert_eq!(
    libc_locales
    .symmetric_difference(&custom_locales)
    .collect::<Vec<_>>(),
    Vec::<&String>::new()
    );
    }
    }
    #[test]
    /// Compare get_locales_libc() with the implementation from gettext-rs
    fn compare_libc_with_gettext() {
    for gettext_category in GETTEXT_CATEGORIES {
    let locale_select_category =
    LocaleSelectCategory::try_from(gettext_category as i32).unwrap();
    let libc_locales = locale_select_category.get_locales_libc();
    let gettext_locales =
    String::from_utf8(gettextrs::setlocale(gettext_category, b"").unwrap()).unwrap();
    assert_eq!(libc_locales[0], gettext_locales);
    }
    }
    #[test]
    /// Compare get_locales_custom() with the implementation from gettext-rs
    fn compare_custom_with_gettext() {
    for gettext_category in GETTEXT_CATEGORIES {
    let locale_select_category =
    LocaleSelectCategory::try_from(gettext_category as i32).unwrap();
    let custom_locales = locale_select_category.get_locales_custom();
    let gettext_locales =
    String::from_utf8(gettextrs::setlocale(gettext_category, b"").unwrap()).unwrap();
    assert_eq!(custom_locales[0], gettext_locales);
    }
    }
  • edit in locale_select/Cargo.toml at line 13
    [2.264]
    [dev-dependencies]
    gettext-rs = "0.7.0"