From 40e02d678c6dc8b2a90abbae8318a174264206dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Tue, 30 Dec 2014 12:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90suffix=5Farray=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/Test/SuffixArrayTest.cpp | 19 ++++++++++++++----- TinySTL/Test/SuffixArrayTest.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/TinySTL/Test/SuffixArrayTest.cpp b/TinySTL/Test/SuffixArrayTest.cpp index 2d94828..a3ae8e8 100644 --- a/TinySTL/Test/SuffixArrayTest.cpp +++ b/TinySTL/Test/SuffixArrayTest.cpp @@ -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 {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 diff --git a/TinySTL/Test/SuffixArrayTest.h b/TinySTL/Test/SuffixArrayTest.h index d7e5001..e6ff62b 100644 --- a/TinySTL/Test/SuffixArrayTest.h +++ b/TinySTL/Test/SuffixArrayTest.h @@ -9,7 +9,7 @@ namespace TinySTL{ namespace SuffixArrayTest{ - + void testCase(); } }