lexmark-fax-pnh: Add unit test for transform() function

Increases unit test coverage to 100%.

BUG=b:248023706
TEST=cros_run_unit_tests --board ${BOARD} --packages lexmark-fax-pnh

Change-Id: If67700a101b48a99c89e542a2862f0a7ca125065
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/lexmark-fax-pnh/+/3914709
Commit-Queue: Bryan Cain <bryancain@chromium.org>
Tested-by: Bryan Cain <bryancain@chromium.org>
Reviewed-by: Benjamin Gordon <bmgordon@chromium.org>
Auto-Submit: Bryan Cain <bryancain@chromium.org>
diff --git a/main.cc b/main.cc
index 1a17450..1d39dc7 100644
--- a/main.cc
+++ b/main.cc
@@ -7,17 +7,6 @@
 
 #include "token_replacer.h"
 
-// Read in the file, line-by-line, apply the transformation to each line, and
-// then write the line to out.
-void transform(const TokenReplacer& replacer,
-               std::istream& in,
-               std::ostream& out) {
-  std::string line;
-  while(std::getline(in, line)) {
-    out << replacer.TokenizeLine(line) << std::endl;
-  }
-}
-
 int main(int argc, char* argv[]) {
   if (argc < 6 || argc > 7) {
     std::cerr << "ERROR: " << argv[0]
diff --git a/token_replacer.cc b/token_replacer.cc
index a8cb3bb..3bdbc3b 100644
--- a/token_replacer.cc
+++ b/token_replacer.cc
@@ -37,4 +37,15 @@
   title = std::regex_replace(title, quote, "'");
 
   return title;
-}
\ No newline at end of file
+}
+
+// Read in the file, line-by-line, apply the transformation to each line, and
+// then write the line to out.
+void transform(const TokenReplacer& replacer,
+               std::istream& in,
+               std::ostream& out) {
+  std::string line;
+  while(std::getline(in, line)) {
+    out << replacer.TokenizeLine(line) << std::endl;
+  }
+}
diff --git a/token_replacer.h b/token_replacer.h
index 9c92e7d..7d0d087 100644
--- a/token_replacer.h
+++ b/token_replacer.h
@@ -5,6 +5,7 @@
 #ifndef __TOKEN_REPLACER_H__
 #define __TOKEN_REPLACER_H__
 
+#include <iostream>
 #include <regex>
 #include <string>
 
@@ -51,4 +52,8 @@
   const std::string copies_replacement_;
 };
 
+void transform(const TokenReplacer& replacer,
+               std::istream& in,
+               std::ostream& out);
+
 #endif // __TOKEN_REPLACER_H__
\ No newline at end of file
diff --git a/token_replacer_test.cc b/token_replacer_test.cc
index 76dfc64..fcadbe4 100644
--- a/token_replacer_test.cc
+++ b/token_replacer_test.cc
@@ -79,6 +79,25 @@
   EXPECT_EQ(replacer.GetTitle(), "this / that");
 }
 
+TEST(Title, Transform) {
+  TokenReplacer replacer("hostname", "user@host.com", "this / that", "42");
+  std::istringstream input(
+    "@PJL SET STATIONID = GETMYHOST\n"
+    "@PJL SET USERNAME = GEYMYUSERNAME\n"
+    "@PJL SET JOBNAME = GETMYJOBNAME\n"
+    "@PJL SET QTY = GETMYCOPIES\n"
+  );
+  std::ostringstream output;
+  std::string expected =
+    "@PJL SET STATIONID = \"hostname\"\n"
+    "@PJL SET USERNAME = \"user@host.com\"\n"
+    "@PJL SET JOBNAME = \"this / that\"\n"
+    "@PJL SET QTY = 42\n";
+
+  transform(replacer, input, output);
+  EXPECT_EQ(output.str(), expected);
+}
+
 TEST_F(TokenReplacerTest, UnchangedLine) {
   EXPECT_EQ(replacer_.TokenizeLine("Unchanged"), "Unchanged");
 }