Skip to content

Commit ec2bbeb

Browse files
committed
fix frequency int overflow
1 parent 5076968 commit ec2bbeb

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/hallelujah.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void HallelujahEngine::loadWords() {
328328
const auto &frequency = value["frequency"];
329329

330330
if (!translation.is_array() || !ipa.is_string() ||
331-
!frequency.is_number_integer()) {
331+
!frequency.is_number()) {
332332
continue;
333333
}
334334
std::vector<std::string> translations;
@@ -339,7 +339,7 @@ void HallelujahEngine::loadWords() {
339339
}
340340
words_.emplace(key, HallelujahWord(std::move(translations),
341341
ipa.get<std::string>(),
342-
frequency.get<int>()));
342+
frequency.get<double>()));
343343
}
344344
}
345345

src/hallelujah.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct HallelujahWord {
3434
: translation_(translation), ipa_(ipa), frequency_(frequency) {}
3535
std::vector<std::string> translation_;
3636
std::string ipa_;
37-
int frequency_;
37+
double frequency_;
3838
};
3939

4040
class HallelujahEngine;

test/testhallelujah.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ std::vector<std::pair<std::vector<std::string>, std::vector<std::string>>>
2121
{{"a", "X", "e", "Return"}, {"aXe"}},
2222
{{"a", ","}, {"a"}}, // comma is passed to client
2323
{{"s", "h", "u", "r", "u", "f", "a", "3"}, {"input method"}},
24+
{{"e", "x", "c", "i", "t", "n", "g", "2"}, {"exciting"}}, // spell check
2425
};
2526

2627
void scheduleEvent(EventDispatcher *dispatcher, Instance *instance) {
@@ -29,17 +30,13 @@ void scheduleEvent(EventDispatcher *dispatcher, Instance *instance) {
2930
FCITX_ASSERT(hallelujah);
3031
auto defaultGroup = instance->inputMethodManager().currentGroup();
3132
defaultGroup.inputMethodList().clear();
32-
defaultGroup.inputMethodList().push_back(
33-
InputMethodGroupItem("keyboard-us"));
3433
defaultGroup.inputMethodList().push_back(
3534
InputMethodGroupItem("hallelujah"));
3635
defaultGroup.setDefaultInputMethod("");
3736
instance->inputMethodManager().setGroup(defaultGroup);
3837
auto *testfrontend = instance->addonManager().addon("testfrontend");
3938
auto uuid =
4039
testfrontend->call<ITestFrontend::createInputContext>("testapp");
41-
testfrontend->call<ITestFrontend::keyEvent>(uuid, Key("Control+space"),
42-
false);
4340
for (const auto &data : expectedCommit) {
4441
for (const auto &expect : data.second) {
4542
testfrontend->call<ITestFrontend::pushCommitExpectation>(

0 commit comments

Comments
 (0)