Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
111c05ff
Commit
111c05ff
authored
10 years ago
by
Keisuke Kuroyanagi
Browse files
Options
Downloads
Patches
Plain Diff
Add BloomFilterTest.
Change-Id: If97b9e9cc3bbaa4c7877991c11d7935626268ca3
parent
26c80662
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
native/jni/NativeFileList.mk
+1
-0
1 addition, 0 deletions
native/jni/NativeFileList.mk
native/jni/tests/suggest/core/dictionary/bloom_filter_test.cpp
+61
-0
61 additions, 0 deletions
...e/jni/tests/suggest/core/dictionary/bloom_filter_test.cpp
with
62 additions
and
0 deletions
native/jni/NativeFileList.mk
+
1
−
0
View file @
111c05ff
...
...
@@ -102,4 +102,5 @@ LATIN_IME_CORE_SRC_FILES := \
LATIN_IME_CORE_TEST_FILES
:=
\
defines_test.cpp
\
suggest/core/layout/normal_distribution_2d_test.cpp
\
suggest/core/dictionary/bloom_filter_test.cpp
\
utils/autocorrection_threshold_utils_test.cpp
This diff is collapsed.
Click to expand it.
native/jni/tests/suggest/core/dictionary/bloom_filter_test.cpp
0 → 100644
+
61
−
0
View file @
111c05ff
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include
"suggest/core/dictionary/bloom_filter.h"
#include
<gtest/gtest.h>
#include
<cstdlib>
#include
<ctime>
#include
<unordered_set>
#include
<vector>
namespace
latinime
{
namespace
{
TEST
(
BloomFilterTest
,
TestFilter
)
{
static
const
int
ELEMENT_COUNT
=
1000
;
srand
(
time
(
0
));
std
::
vector
<
int
>
elements
;
std
::
unordered_set
<
int
>
elementsThatHaveBeenSetInFilter
;
for
(
int
i
=
0
;
i
<
ELEMENT_COUNT
;
++
i
)
{
elements
.
push_back
(
rand
());
}
BloomFilter
bloomFilter
;
for
(
const
int
elem
:
elements
)
{
ASSERT_FALSE
(
bloomFilter
.
isInFilter
(
elem
));
}
for
(
const
int
elem
:
elements
)
{
if
(
rand
()
%
2
==
0
)
{
bloomFilter
.
setInFilter
(
elem
);
elementsThatHaveBeenSetInFilter
.
insert
(
elem
);
}
}
for
(
const
int
elem
:
elements
)
{
const
bool
existsInFilter
=
bloomFilter
.
isInFilter
(
elem
);
const
bool
hasBeenSetInFilter
=
elementsThatHaveBeenSetInFilter
.
find
(
elem
)
!=
elementsThatHaveBeenSetInFilter
.
end
();
if
(
hasBeenSetInFilter
)
{
ASSERT_TRUE
(
existsInFilter
);
}
if
(
!
existsInFilter
)
{
ASSERT_FALSE
(
hasBeenSetInFilter
);
}
}
}
}
// namespace
}
// namespace latinime
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment