summaryrefslogtreecommitdiff
path: root/test/include/json_html_serializer_test.cpp
diff options
context:
space:
mode:
authorOliver Brewka <oliver.brewka@9elements.com>2026-10-02 18:19:25 +0300
committerOliver Brewka <oliver.brewka@9elements.com>2026-11-02 20:00:37 +0300
commitd78bd2e745a47bc7e5c0b0dfe187ce66d507b20c (patch)
treed10cb4aef1e3b46a93e8e1151daecfc0157c80ee /test/include/json_html_serializer_test.cpp
parentdb9f4e381bfa672229e9e08a26bf1bc2a2c038da (diff)
downloadbmcweb-d78bd2e745a47bc7e5c0b0dfe187ce66d507b20c.tar.xz
Uniform unit test file naming
Some unit test file names were not following the naming convention ending with the suffix 'test'. Rename all files to follow that convention. In addition, fix bad formatting that does not pass CI any longer. Tested: Code compiles. Unit tests pass. Change-Id: Ic55eb45f03f0650ceecc9f54cf340677e80d64da Signed-off-by: Oliver Brewka <oliver.brewka@9elements.com>
Diffstat (limited to 'test/include/json_html_serializer_test.cpp')
-rw-r--r--test/include/json_html_serializer_test.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/include/json_html_serializer_test.cpp b/test/include/json_html_serializer_test.cpp
new file mode 100644
index 0000000000..9bbff28b13
--- /dev/null
+++ b/test/include/json_html_serializer_test.cpp
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright OpenBMC Authors
+#include "json_html_serializer.hpp"
+
+#include <nlohmann/json.hpp>
+
+#include <string>
+
+#include <gtest/gtest.h>
+
+namespace json_html_util
+{
+namespace
+{
+
+const std::string boilerplateStart =
+ "<html>\n"
+ "<head>\n"
+ "<title>Redfish API</title>\n"
+ "<link href=\"/styles/redfish.css\" rel=\"stylesheet\">\n"
+ "</head>\n"
+ "<body>\n"
+ "<div class=\"container\">\n"
+ "<img src=\"/images/DMTF_Redfish_logo_2017.svg\" alt=\"redfish\" height=\"406px\" width=\"576px\">\n";
+
+const std::string boilerplateEnd =
+ "</div>\n"
+ "</body>\n"
+ "</html>\n";
+
+TEST(JsonHtmlSerializer, dumpHtmlLink)
+{
+ std::string out;
+ nlohmann::json j;
+ j["@odata.id"] = "/redfish/v1";
+ dumpHtml(out, j);
+ EXPECT_EQ(
+ out,
+ boilerplateStart +
+ "<div class=\"content\">\n"
+ "{<div class=tab>&quot@odata.id&quot: <a href=\"/redfish/v1\">\"/redfish/v1\"</a><br></div>}</div>\n" +
+ boilerplateEnd);
+}
+
+TEST(JsonHtmlSerializer, dumpint)
+{
+ std::string out;
+ nlohmann::json j = 42;
+ dumpHtml(out, j);
+ EXPECT_EQ(out, boilerplateStart + "<div class=\"content\">\n42</div>\n" +
+ boilerplateEnd);
+}
+
+TEST(JsonHtmlSerializer, dumpstring)
+{
+ std::string out;
+ nlohmann::json j = "foobar";
+ dumpHtml(out, j);
+ EXPECT_EQ(out,
+ boilerplateStart + "<div class=\"content\">\n\"foobar\"</div>\n" +
+ boilerplateEnd);
+}
+} // namespace
+} // namespace json_html_util