1+ #include " car_numbers.hpp"
2+ #include " gtest/gtest.h"
3+
4+ TEST (RusCarNumbersTest, EmptyInput) {
5+ EXPECT_EQ (rus_car_numbers (" " ), std::vector<std::string>({}));
6+ }
7+
8+ TEST (RusCarNumbersTest, NoNumbersInText) {
9+ const std::string text = R"(
10+ Just text without license plates.
11+ Examples: 12345, ABCDEF, !@#$%^&*
12+ Similar looking: AB12CD, X9Y9Z9
13+ )" ;
14+ EXPECT_EQ (rus_car_numbers (text), std::vector<std::string>({}));
15+ }
16+
17+ TEST (RusCarNumbersTest, ValidNumbersWithoutRegion) {
18+ const std::string text = R"(
19+ Correct plates: A123BC, E555EE, K321AM
20+ Parking spots: M111MM and T444YX
21+ With trash: A123BC45 -> A123BC
22+ Almost valid: X999XZ -> invalid (Z)
23+ )" ;
24+ EXPECT_EQ (rus_car_numbers (text), std::vector<std::string>({" A123BC" , " E555EE" , " K321AM" ,
25+ " M111MM" , " T444YX" , " A123BC" }));
26+ }
27+
28+ TEST (RusCarNumbersTest, InvalidFormats) {
29+ const std::string text = R"(
30+ Invalid:
31+ ABC123 (wrong order)
32+ 123ABC (starts with digits)
33+ A1B2C3 (alternating)
34+ A123BC45 (with region, but takes A123BC)
35+ A12BC (too short)
36+ Z999ZZ (invalid letter Z)
37+ )" ;
38+ EXPECT_EQ (rus_car_numbers (text), std::vector<std::string>({" A123BC" }));
39+ }
40+
41+ TEST (RusCarNumbersTest, MixedContent) {
42+ const std::string text = R"(
43+ Valid: A777BC and C666CT
44+ Invalid: AB123C, X9Y9Z9
45+ With region: T123TX42 -> T123TX
46+ Trash: !Y222YA@
47+ Almost valid: O999OI -> invalid (I)
48+ )" ;
49+ EXPECT_EQ (rus_car_numbers (text),
50+ std::vector<std::string>({" A777BC" , " C666CT" , " T123TX" , " Y222YA" }));
51+ }
52+
53+ TEST (RusCarNumbersTest, EdgeCases) {
54+ const std::string text = R"(
55+ Edge cases:
56+ A001AX (minimum)
57+ X999XX (maximum)
58+ B000TB (zeros in digits)
59+ H555HH (same letters)
60+ Almost valid:
61+ A000AA0 (extra zero)
62+ Y123YF (invalid F)
63+ )" ;
64+ EXPECT_EQ (rus_car_numbers (text),
65+ std::vector<std::string>({" A001AX" , " X999XX" , " B000TB" , " H555HH" }));
66+ }
67+
68+ TEST (RusCarNumbersTest, AllValidLettersCombinations) {
69+ const std::string text = R"(
70+ All valid letters:
71+ A123BC, B456TE, E789KX
72+ K321AM, M111MO, H555OP
73+ O999PC, P777CT, C666TY
74+ T444YX, Y222XA, X888AB
75+ )" ;
76+ EXPECT_EQ (
77+ rus_car_numbers (text),
78+ std::vector<std::string>({" A123BC" , " B456TE" , " E789KX" , " K321AM" , " M111MO" , " H555OP" ,
79+ " O999PC" , " P777CT" , " C666TY" , " T444YX" , " Y222XA" , " X888AB" }));
80+ }
0 commit comments