Skip to content

Commit 9db3368

Browse files
committed
Fixes
1 parent 8e9917e commit 9db3368

5 files changed

Lines changed: 32 additions & 31 deletions

File tree

src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
use serde_json::Value;
88

99
/// Config struct for configuring RitiContext.
10-
#[derive(Clone)]
10+
#[derive(Clone, Debug)]
1111
pub struct Config {
1212
layout: String,
1313
database_dir: PathBuf,
@@ -231,7 +231,7 @@ pub fn get_user_data_dir() -> PathBuf {
231231
// Windows
232232
var("localappdata")
233233
.ok()
234-
.map(|path| path + "/OpenBangla Keyboard")
234+
.map(|path| path + "\\OpenBangla")
235235
})
236236
.unwrap()
237237
.into()
@@ -307,7 +307,7 @@ mod tests {
307307
fn test_data_dir_windows() {
308308
assert_eq!(
309309
get_user_data_dir(),
310-
PathBuf::from(var("localappdata").unwrap() + "/OpenBangla Keyboard")
310+
PathBuf::from(var("localappdata").unwrap() + "\\OpenBangla")
311311
)
312312
}
313313

src/data.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,20 @@ impl Data {
4646
#[cfg(test)]
4747
mod tests {
4848
use super::Data;
49-
use crate::config::get_phonetic_method_defaults;
5049

5150
#[test]
5251
fn test_suffix() {
52+
let db = Data::new();
53+
5354
assert_eq!(db.find_suffix("gulo"), Some("গুলো"));
5455
assert_eq!(db.find_suffix("er"), Some("ের"));
5556
assert_eq!(db.find_suffix("h"), None);
5657
}
5758

5859
#[test]
5960
fn test_autocorrect() {
61+
let db = Data::new();
62+
6063
assert_eq!(db.search_corrected("academy"), Some("oZakaDemi"));
6164
assert_eq!(db.search_corrected("\\nai\\"), None);
6265
}

src/fixed/method.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ mod tests {
576576
fn test_suggestions() {
577577
let mut method = FixedMethod::default();
578578
let config = get_fixed_method_defaults();
579-
let data = Data::new(&config);
579+
let data = Data::new();
580580

581581
method.buffer = "[".to_string();
582582
method.create_dictionary_suggestion(&data, &config);
@@ -607,7 +607,7 @@ mod tests {
607607
fn test_suggestions_with_english_word() {
608608
let mut method = FixedMethod::default();
609609
let mut config = get_fixed_method_defaults();
610-
let data = Data::new(&config);
610+
let data = Data::new();
611611
config.set_suggestion_include_english(true);
612612

613613
method.get_suggestion(VC_A, 0, 0, &data, &config);
@@ -626,7 +626,7 @@ mod tests {
626626
fn test_suggestion_smart_quote() {
627627
let mut method = FixedMethod::default();
628628
let mut config = get_fixed_method_defaults();
629-
let data = Data::new(&config);
629+
let data = Data::new();
630630
config.set_suggestion_include_english(true);
631631

632632
config.set_smart_quote(true);
@@ -652,7 +652,7 @@ mod tests {
652652

653653
let mut method = FixedMethod::default();
654654
let mut config = get_fixed_method_defaults();
655-
let data = Data::new(&config);
655+
let data = Data::new();
656656
config.set_fixed_traditional_kar(false);
657657

658658
method.get_suggestion(VC_SEMICOLON, 0, 0, &data, &config);
@@ -702,7 +702,7 @@ mod tests {
702702
fn test_suggestion_ansi() {
703703
let mut method = FixedMethod::default();
704704
let mut config = get_fixed_method_defaults();
705-
let data = Data::new(&config);
705+
let data = Data::new();
706706
config.set_suggestion_include_english(true);
707707
config.set_ansi_encoding(true);
708708

@@ -740,7 +740,7 @@ mod tests {
740740
};
741741

742742
let mut config = get_fixed_method_defaults();
743-
let data = Data::new(&config);
743+
let data = Data::new();
744744
config.set_fixed_suggestion(false);
745745

746746
assert!(!method.backspace_event(false, &data, &config).is_empty()); // আম
@@ -878,7 +878,7 @@ mod tests {
878878
fn test_suggestion_traditional_kar() {
879879
let mut method = FixedMethod::default();
880880
let mut config = get_fixed_method_defaults();
881-
let data = Data::new(&config);
881+
let data = Data::new();
882882

883883
/* With Traditional Kar Joining */
884884
method.process_key_value("হ", &config);
@@ -931,7 +931,7 @@ mod tests {
931931
fn test_old_kar_order() {
932932
let mut method = FixedMethod::default();
933933
let mut config = get_fixed_method_defaults();
934-
let data = Data::new(&config);
934+
let data = Data::new();
935935
config.set_fixed_old_kar_order(true);
936936

937937
method.buffer = "".to_string();

src/phonetic/method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ mod tests {
201201
#[test]
202202
fn test_backspace() {
203203
let config = get_phonetic_method_defaults();
204-
let data = Data::new(&config);
204+
let data = Data::new();
205205
let mut method = PhoneticMethod {
206206
buffer: "ab".to_string(),
207207
..Default::default()
@@ -221,7 +221,7 @@ mod tests {
221221
#[test]
222222
fn test_preserve_selection() {
223223
let config = get_phonetic_method_defaults();
224-
let data = Data::new(&config);
224+
let data = Data::new();
225225
let mut method = PhoneticMethod {
226226
buffer: "coffee".to_string(),
227227
..Default::default()

src/phonetic/suggestion.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ mod tests {
348348
let mut suggestion = PhoneticSuggestion::default();
349349
let mut selections = HashMap::with_hasher(RandomState::new());
350350
let mut config = get_phonetic_method_defaults();
351-
let data = Data::new(&config);
351+
let data = Data::new();
352352
config.set_suggestion_include_english(true);
353353

354354
suggestion.suggest(":)", &data, &mut selections, &config);
@@ -382,7 +382,7 @@ mod tests {
382382
let mut suggestion = PhoneticSuggestion::default();
383383
let mut selections = HashMap::with_hasher(RandomState::new());
384384
let mut config = get_phonetic_method_defaults();
385-
let data = Data::new(&config);
385+
let data = Data::new();
386386
config.set_suggestion_include_english(true);
387387
config.set_ansi_encoding(true);
388388

@@ -404,7 +404,7 @@ mod tests {
404404
let mut suggestion = PhoneticSuggestion::default();
405405
let mut selections = HashMap::with_hasher(RandomState::new());
406406
let mut config = get_phonetic_method_defaults();
407-
let data = Data::new(&config);
407+
let data = Data::new();
408408
config.set_suggestion_include_english(true);
409409
config.set_smart_quote(true);
410410

@@ -436,7 +436,7 @@ mod tests {
436436
let mut suggestion = PhoneticSuggestion::default();
437437
let mut selections = HashMap::with_hasher(RandomState::new());
438438
let config = get_phonetic_method_defaults();
439-
let data = Data::new(&config);
439+
let data = Data::new();
440440

441441
suggestion.suggest(":)", &data, &mut selections, &config);
442442
assert_eq!(suggestion.suggestions, ["😃", ":)", "ঃ", "ঃ)"]);
@@ -471,7 +471,7 @@ mod tests {
471471
let mut suggestion = PhoneticSuggestion::default();
472472
let mut selections = HashMap::with_hasher(RandomState::new());
473473
let config = get_phonetic_method_defaults();
474-
let data = Data::new(&config);
474+
let data = Data::new();
475475

476476
suggestion.suggest("a", &data, &mut selections, &config);
477477
assert_eq!(
@@ -511,7 +511,7 @@ mod tests {
511511
let mut suggestion = PhoneticSuggestion::default();
512512
let mut selections = HashMap::with_hasher(RandomState::new());
513513
let config = get_phonetic_method_defaults();
514-
let data = Data::new(&config);
514+
let data = Data::new();
515515

516516
suggestion.suggest("a", &data, &mut selections, &config);
517517
suggestion.suggest("ap", &data, &mut selections, &config);
@@ -597,8 +597,7 @@ mod tests {
597597
#[test]
598598
fn test_suffix() {
599599
let mut cache = HashMap::with_hasher(RandomState::new());
600-
let config = get_phonetic_method_defaults();
601-
let data = Data::new(&config);
600+
let data = Data::new();
602601

603602
cache.insert(
604603
"computer".to_string(),
@@ -652,8 +651,7 @@ mod tests {
652651
fn test_prev_selected() {
653652
let mut suggestion = PhoneticSuggestion::default();
654653
let mut selections = HashMap::with_hasher(RandomState::new());
655-
let config = get_phonetic_method_defaults();
656-
let data = Data::new(&config);
654+
let data = Data::new();
657655

658656
selections.insert("onno".to_string(), "অন্য".to_string());
659657
selections.insert("i".to_string(), "ই".to_string());
@@ -735,7 +733,7 @@ mod tests {
735733
let mut suggestion = PhoneticSuggestion::default();
736734
let mut selections = HashMap::with_hasher(RandomState::new());
737735
let config = get_phonetic_method_defaults();
738-
let data = Data::new(&config);
736+
let data = Data::new();
739737
selections.insert("sesh".to_string(), "শেষ".to_string());
740738

741739
let (suggestions, selection) = suggestion.suggest("sesh", &data, &mut selections, &config);
@@ -784,7 +782,7 @@ mod benches {
784782
fn bench_phonetic_a(b: &mut Bencher) {
785783
let mut suggestion = PhoneticSuggestion::default();
786784
let config = get_phonetic_method_defaults();
787-
let data = Data::new(&config);
785+
let data = Data::new();
788786
let term = SplittedString::split("a", false);
789787

790788
b.iter(|| {
@@ -797,7 +795,7 @@ mod benches {
797795
fn bench_phonetic_kkhet(b: &mut Bencher) {
798796
let mut suggestion = PhoneticSuggestion::default();
799797
let config = get_phonetic_method_defaults();
800-
let data = Data::new(&config);
798+
let data = Data::new();
801799
let term = SplittedString::split("kkhet", false);
802800

803801
b.iter(|| {
@@ -810,7 +808,7 @@ mod benches {
810808
fn bench_phonetic_bistari(b: &mut Bencher) {
811809
let mut suggestion = PhoneticSuggestion::default();
812810
let config = get_phonetic_method_defaults();
813-
let data = Data::new(&config);
811+
let data = Data::new();
814812
let term = SplittedString::split("bistari", false);
815813

816814
b.iter(|| {
@@ -823,7 +821,7 @@ mod benches {
823821
fn bench_phonetic_database_a(b: &mut Bencher) {
824822
let config = get_phonetic_method_defaults();
825823
let mut suggestion = PhoneticSuggestion::default();
826-
let data = Data::new(&config);
824+
let data = Data::new();
827825
b.iter(|| {
828826
let mut suggestions = Vec::new();
829827
suggestion.include_from_dictionary("a", "", &mut suggestions);
@@ -835,7 +833,7 @@ mod benches {
835833
fn bench_phonetic_database_aro(b: &mut Bencher) {
836834
let config = get_phonetic_method_defaults();
837835
let mut suggestion = PhoneticSuggestion::default();
838-
let data = Data::new(&config);
836+
let data = Data::new();
839837
b.iter(|| {
840838
let mut suggestions = Vec::new();
841839
suggestion.include_from_dictionary("arO", "", &mut suggestions);
@@ -847,7 +845,7 @@ mod benches {
847845
fn bench_phonetic_database_bistari(b: &mut Bencher) {
848846
let config = get_phonetic_method_defaults();
849847
let mut suggestion = PhoneticSuggestion::default();
850-
let data = Data::new(&config);
848+
let data = Data::new();
851849
b.iter(|| {
852850
let mut suggestions = Vec::new();
853851
suggestion.include_from_dictionary("bistari", "", &mut suggestions);

0 commit comments

Comments
 (0)