Skip to content

Commit f413955

Browse files
committed
Tests for 516. Longest Palindromic Subsequence
1 parent c4f6c29 commit f413955

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

test/leetcode_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import 'medium/3.longest_substring_without_repeating_characters.test.dart'
2929
import 'medium/424.longest_repeating_character_replacement.test.dart' as longest_repeating_character_replacement;
3030
import 'medium/49.group_anagrams.test.dart' as group_anagrams;
3131
import 'medium/5.longest_palindromic_substring.test.dart' as longest_palindromic_substring;
32+
import 'medium/516.longest_palindromic_subsequence.test.dart' as longest_palindromic_subsequence;
3233
import 'medium/647.palindromic_substrings.test.dart' as palindromic_substrings;
3334
import 'medium/912.sort_an_array.test.dart' as sort_an_array;
3435

@@ -62,5 +63,6 @@ void main() {
6263
group_anagrams.main();
6364
longest_palindromic_substring.main();
6465
palindromic_substrings.main();
66+
longest_palindromic_subsequence.main();
6567
});
6668
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import 'package:leetcode/src/medium/516.longest_palindromic_subsequence/main.dart';
2+
import 'package:test/test.dart';
3+
4+
void main() {
5+
group('sort_an_array', () {
6+
final f = Solution().longestPalindromeSubseq;
7+
8+
test('returns 1 for single-character input', () {
9+
expect(f('a'), equals(1));
10+
});
11+
12+
test('returns correct length for even-length palindromes', () {
13+
expect(f('abba'), equals(4));
14+
expect(f('racecar'), equals(7));
15+
});
16+
17+
test('returns correct length for odd-length palindromes', () {
18+
expect(f('aba'), equals(3));
19+
expect(f('level'), equals(5));
20+
});
21+
22+
test('returns correct length for non-palindromic input', () {
23+
expect(f('abc'), equals(1));
24+
expect(f('leetcode'), equals(3));
25+
});
26+
27+
test('returns correct length for other possible palindromes', () {
28+
expect(f('bbbab'), equals(4));
29+
expect(f('cbbd'), equals(2));
30+
});
31+
}); // group 'sort_an_array'
32+
}

0 commit comments

Comments
 (0)