1*8d2f868cSEd Tanous 
2*8d2f868cSEd Tanous #include "systems_logservices_postcodes.hpp"
3*8d2f868cSEd Tanous 
4*8d2f868cSEd Tanous #include <cstdint>
5*8d2f868cSEd Tanous 
6*8d2f868cSEd Tanous #include <gtest/gtest.h>
7*8d2f868cSEd Tanous 
8*8d2f868cSEd Tanous namespace redfish
9*8d2f868cSEd Tanous {
10*8d2f868cSEd Tanous namespace
11*8d2f868cSEd Tanous {
12*8d2f868cSEd Tanous 
TEST(LogServicesPostCodeParse,PostCodeParse)13*8d2f868cSEd Tanous TEST(LogServicesPostCodeParse, PostCodeParse)
14*8d2f868cSEd Tanous {
15*8d2f868cSEd Tanous     uint64_t currentValue = 0;
16*8d2f868cSEd Tanous     uint16_t index = 0;
17*8d2f868cSEd Tanous     EXPECT_TRUE(parsePostCode("B1-2", currentValue, index));
18*8d2f868cSEd Tanous     EXPECT_EQ(currentValue, 2);
19*8d2f868cSEd Tanous     EXPECT_EQ(index, 1);
20*8d2f868cSEd Tanous     EXPECT_TRUE(parsePostCode("B200-300", currentValue, index));
21*8d2f868cSEd Tanous     EXPECT_EQ(currentValue, 300);
22*8d2f868cSEd Tanous     EXPECT_EQ(index, 200);
23*8d2f868cSEd Tanous 
24*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("", currentValue, index));
25*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B", currentValue, index));
26*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B1", currentValue, index));
27*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B1-", currentValue, index));
28*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B1A-2", currentValue, index));
29*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B1A-2", currentValue, index));
30*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B1A-2z", currentValue, index));
31*8d2f868cSEd Tanous     // Uint16_t max + 1
32*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B65536-1", currentValue, index));
33*8d2f868cSEd Tanous 
34*8d2f868cSEd Tanous     // Uint64_t max + 1
35*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B1-18446744073709551616", currentValue, index));
36*8d2f868cSEd Tanous 
37*8d2f868cSEd Tanous     // Negative numbers
38*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B-1-2", currentValue, index));
39*8d2f868cSEd Tanous     EXPECT_FALSE(parsePostCode("B-1--2", currentValue, index));
40*8d2f868cSEd Tanous }
41*8d2f868cSEd Tanous 
42*8d2f868cSEd Tanous } // namespace
43*8d2f868cSEd Tanous } // namespace redfish
44