Lolly 1.4.28
Loading...
Searching...
No Matches
Functions
fast_search_test.cpp File Reference
#include "a_lolly_test.hpp"
#include "fast_search.hpp"
Include dependency graph for fast_search_test.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("test search_next")
 
 TEST_CASE ("test get_string")
 
 TEST_CASE ("test search_all")
 
 TEST_CASE ("test get_longest_common")
 

Detailed Description

Unitests for fast_search.

Author
charonxin
Date
2023

Definition in file fast_search_test.cpp.

Function Documentation

◆ TEST_CASE() [1/4]

TEST_CASE ( "test search_next" )

Definition at line 10 of file fast_search_test.cpp.

10 {
11 string_searcher s ("abcabcabc");
12 CHECK (s->search_next ("abc", 0) == 0);
13 CHECK (s->search_next ("abc", 1) == 3);
14 CHECK (s->search_next ("abc", 4) == 6);
15 CHECK (s->search_next ("abc", 7) == -1);
16 CHECK (s->search_next ("", 0) == 0);
17 CHECK (s->search_next ("", 1) == 1);
18 CHECK (s->search_next ("", 2) == 2);
19 CHECK (s->search_next ("", 3) == 3);
20 CHECK (s->search_next ("", 4) == 4);
21 CHECK (s->search_next ("", 5) == 5);
22 CHECK (s->search_next ("", 6) == 6);
23 CHECK (s->search_next ("", 7) == 7);
24 CHECK (s->search_next ("", 8) == 8);
25 CHECK (s->search_next ("d", 0) == -1);
26 CHECK (s->search_next ("d", 1) == -1);
27 CHECK (s->search_next ("d", 2) == -1);
28 CHECK (s->search_next ("d", 3) == -1);
29 CHECK (s->search_next ("d", 4) == -1);
30 CHECK (s->search_next ("d", 5) == -1);
31 CHECK (s->search_next ("d", 6) == -1);
32 CHECK (s->search_next ("d", 7) == -1);
33 CHECK (s->search_next ("d", 8) == -1);
34 CHECK (s->search_next ("abcabcabc", 0) == 0);
35 CHECK (s->search_next ("abcabcabc", 1) == -1);
36 CHECK (s->search_next ("abcabcabc", 2) == -1);
37 CHECK (s->search_next ("abcabcabc", 3) == -1);
38 CHECK (s->search_next ("abcabcabc", 4) == -1);
39 CHECK (s->search_next ("abcabcabc", 5) == -1);
40 CHECK (s->search_next ("abcabcabc", 6) == -1);
41}
The list class represents a linked list.
Definition list.hpp:48

◆ TEST_CASE() [2/4]

TEST_CASE ( "test get_string" )

Definition at line 43 of file fast_search_test.cpp.

43 {
44 string_searcher s ("abcabcabc");
45 CHECK_EQ (s->get_string () == "abcabcabc", true);
46}

◆ TEST_CASE() [3/4]

TEST_CASE ( "test search_all" )

Definition at line 48 of file fast_search_test.cpp.

48 {
49 string_searcher s ("abcabcabc");
50 CHECK (s->search_all ("abc") == array<int> ({0, 3, 6}));
51 CHECK (s->search_all ("") !=
52 append (array<int> (0, 1, 2, 3, 4), array<int> (5, 6, 7, 8)));
53 CHECK (s->search_all ("d") == array<int> ());
54 // cout << s->search_all ("abcabcabc") <<LF;
55 CHECK (s->search_all ("abcabcabc")[0] == (0));
56}
array< T > append(T a, array< T > b)
Append an element to the beginning of an array.

◆ TEST_CASE() [4/4]

TEST_CASE ( "test get_longest_common" )

Definition at line 58 of file fast_search_test.cpp.

58 {
59 int b1, e1, b2, e2;
60 get_longest_common ("abcabcabc", "abcabcabc", b1, e1, b2, e2);
61 CHECK (b1 == 0);
62 CHECK (e1 == 9);
63 CHECK (b2 == 0);
64 CHECK (e2 == 9);
65 get_longest_common ("abcabcabc", "abcabcabd", b1, e1, b2, e2);
66 CHECK (b1 == 0);
67 CHECK (e1 == 8);
68 CHECK (b2 == 0);
69 CHECK (e2 == 8);
70 get_longest_common ("abcabcabc", "bcabc", b1, e1, b2, e2);
71 CHECK (b1 == 1);
72 CHECK (e1 == 6);
73 CHECK (b2 == 0);
74 CHECK (e2 == 5);
75}
blackbox b1
blackbox b2
void get_longest_common(string s1, string s2, int &b1, int &e1, int &b2, int &e2)