提交 40e02d67 编写于 作者: 邹晓航

完成suffix_array单元测试

上级 9ba00858
......@@ -2,20 +2,29 @@
namespace TinySTL{
namespace SuffixArrayTest{
void testCase1(){
void testCase(){
char arr[] = { 'a', 'a', 'b', 'a', 'a', 'a', 'a', 'b' };
TinySTL::suffix_array sa(arr, 8);
auto v = sa.suffixArray();
auto t = std::vector<int> {3, 4, 5, 0, 6, 1, 7, 2};
assert(TinySTL::Test::container_equal(v, t));
auto sa1 = sa.suffixArray();
auto sa2 = TinySTL::suffix_array::array_type{3, 4, 5, 0, 6, 1, 7, 2};
assert(TinySTL::Test::container_equal(sa1, sa2));
auto ra1 = sa.rankArray();
auto ra2 = TinySTL::suffix_array::array_type{ 3, 5, 7, 0, 1, 2, 4, 6 };
assert(TinySTL::Test::container_equal(ra1, ra2));
auto ha1 = sa.heightArray();
auto ha2 = TinySTL::suffix_array::array_type{ 3, 2, 3, 1, 2, 0, 1 };
assert(TinySTL::Test::container_equal(ha1, ha2));
}
}
}
using namespace TinySTL::SuffixArrayTest;
int main(){
testCase1();
testCase();
system("pause");
return 0;
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
namespace TinySTL{
namespace SuffixArrayTest{
void testCase();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册