| 24 | }; |
| 25 | |
| 26 | void make_sure_ok(string s) { |
| 27 | // s = s + "~"; |
| 28 | suffix_array sa1(s); |
| 29 | naive_suffix_array sa2(s); |
| 30 | |
| 31 | // for (int i = 0; i < size(s); i++) { |
| 32 | // cout << s.substr(sa1.idx[i]) << endl; |
| 33 | // } |
| 34 | |
| 35 | // cout << endl; |
| 36 | // for (int i = 0; i < size(s); i++) { |
| 37 | // cout << s.substr(sa2.idx[i]) << endl; |
| 38 | // } |
| 39 | |
| 40 | // cout << endl; |
| 41 | |
| 42 | for (int i = 0; i < size(s); i++) { |
| 43 | |
| 44 | assert_equal(sa1.idx[i], sa2.idx[i]); |
| 45 | |
| 46 | if (sa1.idx[i] != sa2.idx[i]) |
| 47 | { |
| 48 | cout << s << endl; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | void test() { |
| 54 | make_sure_ok("GATAGACA"); |