OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/html/HTMLSlotElement.h" | 5 #include "core/html/HTMLSlotElement.h" |
6 | 6 |
7 #include <array> | 7 #include <array> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 namespace { | 13 namespace { |
14 constexpr int kTableSize = 16; | 14 constexpr int kTableSize = 16; |
15 using Seq = std::vector<char>; | 15 using Seq = std::vector<char>; |
16 using Backtrack = std::pair<size_t, size_t>; | 16 using Backtrack = std::pair<size_t, size_t>; |
17 } | 17 } |
18 | 18 |
19 class HTMLSlotElementTest : public testing::Test { | 19 class HTMLSlotElementTest : public ::testing::Test { |
20 protected: | 20 protected: |
21 HTMLSlotElementTest() {} | 21 HTMLSlotElementTest() {} |
22 Seq LongestCommonSubsequence(const Seq& seq1, const Seq& seq2); | 22 Seq LongestCommonSubsequence(const Seq& seq1, const Seq& seq2); |
23 std::array<std::array<size_t, kTableSize>, kTableSize> lcs_table_; | 23 std::array<std::array<size_t, kTableSize>, kTableSize> lcs_table_; |
24 std::array<std::array<Backtrack, kTableSize>, kTableSize> backtrack_table_; | 24 std::array<std::array<Backtrack, kTableSize>, kTableSize> backtrack_table_; |
25 }; | 25 }; |
26 | 26 |
27 std::vector<char> HTMLSlotElementTest::LongestCommonSubsequence( | 27 std::vector<char> HTMLSlotElementTest::LongestCommonSubsequence( |
28 const Seq& seq1, | 28 const Seq& seq1, |
29 const Seq& seq2) { | 29 const Seq& seq2) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // If we use kTableSize here, it should hit DCHECK(). | 122 // If we use kTableSize here, it should hit DCHECK(). |
123 std::fill_n(std::back_inserter(seq1), kTableSize - 1, 'a'); | 123 std::fill_n(std::back_inserter(seq1), kTableSize - 1, 'a'); |
124 Seq seq2; | 124 Seq seq2; |
125 std::fill_n(std::back_inserter(seq2), kTableSize - 1, 'a'); | 125 std::fill_n(std::back_inserter(seq2), kTableSize - 1, 'a'); |
126 Seq lcs; | 126 Seq lcs; |
127 std::fill_n(std::back_inserter(lcs), kTableSize - 1, 'a'); | 127 std::fill_n(std::back_inserter(lcs), kTableSize - 1, 'a'); |
128 EXPECT_EQ(lcs, LongestCommonSubsequence(seq1, seq2)); | 128 EXPECT_EQ(lcs, LongestCommonSubsequence(seq1, seq2)); |
129 } | 129 } |
130 | 130 |
131 } // namespace blink | 131 } // namespace blink |
OLD | NEW |