summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/redfish-core/lib/log_services_test.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/redfish-core/lib/log_services_test.cpp b/test/redfish-core/lib/log_services_test.cpp
index 631e3d159f..5dc04c8863 100644
--- a/test/redfish-core/lib/log_services_test.cpp
+++ b/test/redfish-core/lib/log_services_test.cpp
@@ -63,5 +63,34 @@ TEST(LogServicesBMCJouralTest, LogServicesBMCJouralGetReturnsError)
EXPECT_EQ(indexOut, indexIn);
}
+TEST(LogServicesPostCodeParse, PostCodeParse)
+{
+ uint64_t currentValue = 0;
+ uint16_t index = 0;
+ EXPECT_TRUE(parsePostCode("B1-2", currentValue, index));
+ EXPECT_EQ(currentValue, 2);
+ EXPECT_EQ(index, 1);
+ EXPECT_TRUE(parsePostCode("B200-300", currentValue, index));
+ EXPECT_EQ(currentValue, 300);
+ EXPECT_EQ(index, 200);
+
+ EXPECT_FALSE(parsePostCode("", currentValue, index));
+ EXPECT_FALSE(parsePostCode("B", currentValue, index));
+ EXPECT_FALSE(parsePostCode("B1", currentValue, index));
+ EXPECT_FALSE(parsePostCode("B1-", currentValue, index));
+ EXPECT_FALSE(parsePostCode("B1A-2", currentValue, index));
+ EXPECT_FALSE(parsePostCode("B1A-2", currentValue, index));
+ EXPECT_FALSE(parsePostCode("B1A-2z", currentValue, index));
+ // Uint16_t max + 1
+ EXPECT_FALSE(parsePostCode("B65536-1", currentValue, index));
+
+ // Uint64_t max + 1
+ EXPECT_FALSE(parsePostCode("B1-18446744073709551616", currentValue, index));
+
+ // Negative numbers
+ EXPECT_FALSE(parsePostCode("B-1-2", currentValue, index));
+ EXPECT_FALSE(parsePostCode("B-1--2", currentValue, index));
+}
+
} // namespace
} // namespace redfish