Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
6929b086
T
Terarkdb
项目概览
indiff7643
/
Terarkdb
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Terarkdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6929b086
编写于
8月 19, 2014
作者:
I
Igor Canadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove BitStream* tests
上级
50b790c6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
93 deletion
+0
-93
util/coding_test.cc
util/coding_test.cc
+0
-93
未找到文件。
util/coding_test.cc
浏览文件 @
6929b086
...
...
@@ -196,99 +196,6 @@ TEST(Coding, Strings) {
ASSERT_EQ
(
""
,
input
.
ToString
());
}
TEST
(
Coding
,
BitStream
)
{
const
int
kNumBytes
=
10
;
char
bytes
[
kNumBytes
+
1
];
for
(
int
i
=
0
;
i
<
kNumBytes
+
1
;
++
i
)
{
bytes
[
i
]
=
'\0'
;
}
// Simple byte aligned test.
for
(
int
i
=
0
;
i
<
kNumBytes
;
++
i
)
{
BitStreamPutInt
(
bytes
,
kNumBytes
,
i
*
8
,
8
,
255
-
i
);
ASSERT_EQ
((
unsigned
char
)
bytes
[
i
],
(
unsigned
char
)(
255
-
i
));
}
for
(
int
i
=
0
;
i
<
kNumBytes
;
++
i
)
{
ASSERT_EQ
(
BitStreamGetInt
(
bytes
,
kNumBytes
,
i
*
8
,
8
),
(
uint32_t
)(
255
-
i
));
}
ASSERT_EQ
(
bytes
[
kNumBytes
],
'\0'
);
// Write and read back at strange offsets
for
(
int
i
=
0
;
i
<
kNumBytes
+
1
;
++
i
)
{
bytes
[
i
]
=
'\0'
;
}
for
(
int
i
=
0
;
i
<
kNumBytes
;
++
i
)
{
BitStreamPutInt
(
bytes
,
kNumBytes
,
i
*
5
+
1
,
4
,
(
i
*
7
)
%
(
1
<<
4
));
}
for
(
int
i
=
0
;
i
<
kNumBytes
;
++
i
)
{
ASSERT_EQ
(
BitStreamGetInt
(
bytes
,
kNumBytes
,
i
*
5
+
1
,
4
),
(
uint32_t
)((
i
*
7
)
%
(
1
<<
4
)));
}
ASSERT_EQ
(
bytes
[
kNumBytes
],
'\0'
);
// Create 11011011 as a bit pattern
for
(
int
i
=
0
;
i
<
kNumBytes
+
1
;
++
i
)
{
bytes
[
i
]
=
'\0'
;
}
for
(
int
i
=
0
;
i
<
kNumBytes
;
++
i
)
{
BitStreamPutInt
(
bytes
,
kNumBytes
,
i
*
8
,
2
,
3
);
BitStreamPutInt
(
bytes
,
kNumBytes
,
i
*
8
+
3
,
2
,
3
);
BitStreamPutInt
(
bytes
,
kNumBytes
,
i
*
8
+
6
,
2
,
3
);
ASSERT_EQ
((
unsigned
char
)
bytes
[
i
],
(
unsigned
char
)(
3
+
(
3
<<
3
)
+
(
3
<<
6
)));
}
ASSERT_EQ
(
bytes
[
kNumBytes
],
'\0'
);
// Test large values
for
(
int
i
=
0
;
i
<
kNumBytes
+
1
;
++
i
)
{
bytes
[
i
]
=
'\0'
;
}
BitStreamPutInt
(
bytes
,
kNumBytes
,
0
,
64
,
(
uint64_t
)(
-
1
));
for
(
int
i
=
0
;
i
<
64
/
8
;
++
i
)
{
ASSERT_EQ
((
unsigned
char
)
bytes
[
i
],
(
unsigned
char
)(
255
));
}
ASSERT_EQ
(
bytes
[
64
/
8
],
'\0'
);
}
TEST
(
Coding
,
BitStreamConvenienceFuncs
)
{
std
::
string
bytes
(
1
,
'\0'
);
// Check that independent changes to byte are preserved.
BitStreamPutInt
(
&
bytes
,
0
,
2
,
3
);
BitStreamPutInt
(
&
bytes
,
3
,
2
,
3
);
BitStreamPutInt
(
&
bytes
,
6
,
2
,
3
);
ASSERT_EQ
((
unsigned
char
)
bytes
[
0
],
(
unsigned
char
)(
3
+
(
3
<<
3
)
+
(
3
<<
6
)));
ASSERT_EQ
(
BitStreamGetInt
(
&
bytes
,
0
,
2
),
3u
);
ASSERT_EQ
(
BitStreamGetInt
(
&
bytes
,
3
,
2
),
3u
);
ASSERT_EQ
(
BitStreamGetInt
(
&
bytes
,
6
,
2
),
3u
);
Slice
slice
(
bytes
);
ASSERT_EQ
(
BitStreamGetInt
(
&
slice
,
0
,
2
),
3u
);
ASSERT_EQ
(
BitStreamGetInt
(
&
slice
,
3
,
2
),
3u
);
ASSERT_EQ
(
BitStreamGetInt
(
&
slice
,
6
,
2
),
3u
);
// Test overlapping crossing over byte boundaries
bytes
=
std
::
string
(
2
,
'\0'
);
BitStreamPutInt
(
&
bytes
,
6
,
4
,
15
);
ASSERT_EQ
((
unsigned
char
)
bytes
[
0
],
3
<<
6
);
ASSERT_EQ
((
unsigned
char
)
bytes
[
1
],
3
);
ASSERT_EQ
(
BitStreamGetInt
(
&
bytes
,
6
,
4
),
15u
);
slice
=
Slice
(
bytes
);
ASSERT_EQ
(
BitStreamGetInt
(
&
slice
,
6
,
4
),
15u
);
// Test 64-bit number
bytes
=
std
::
string
(
64
/
8
,
'\0'
);
BitStreamPutInt
(
&
bytes
,
0
,
64
,
(
uint64_t
)(
-
1
));
ASSERT_EQ
(
BitStreamGetInt
(
&
bytes
,
0
,
64
),
(
uint64_t
)(
-
1
));
slice
=
Slice
(
bytes
);
ASSERT_EQ
(
BitStreamGetInt
(
&
slice
,
0
,
64
),
(
uint64_t
)(
-
1
));
}
}
// namespace rocksdb
int
main
(
int
argc
,
char
**
argv
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录