Add test coverage for private_optional + template_streamop combined; fix generator bugs (#14)


* Add test coverage for private_optional + template_streamop combined, fix generator bugs


Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: zsy056 <1074382+zsy056@users.noreply.github.com>
diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am
index 720a4b3..a17a3fb 100644
--- a/test/cpp/Makefile.am
+++ b/test/cpp/Makefile.am
@@ -31,7 +31,10 @@
                 gen-cpp-enumclass/ThriftTest_constants.cpp \
                 gen-cpp-templatestreamop/ThriftTest_types.cpp \
                 gen-cpp-templatestreamop/ThriftTest_types.tcc \
-                gen-cpp-templatestreamop/ThriftTest_constants.cpp
+                gen-cpp-templatestreamop/ThriftTest_constants.cpp \
+                gen-cpp-private-templatestreamop/ThriftTest_types.cpp \
+                gen-cpp-private-templatestreamop/ThriftTest_types.tcc \
+                gen-cpp-private-templatestreamop/ThriftTest_constants.cpp
 
 noinst_LTLIBRARIES = libtestgencpp.la libstresstestgencpp.la
 nodist_libtestgencpp_la_SOURCES = \
@@ -55,7 +58,8 @@
 	libforwardsettertestgencpp.la \
 	libprivateoptonaltestgencpp.la \
 	libenumclasstestgencpp.la \
-	libtemplatestreamoptestgencpp.la
+	libtemplatestreamoptestgencpp.la \
+	libprivateopttemplstreamoptestgencpp.la
 
 nodist_libforwardsettertestgencpp_la_SOURCES = \
 	gen-cpp-forward/ThriftTest_types.cpp \
@@ -95,6 +99,16 @@
 
 libtemplatestreamoptestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la
 
+nodist_libprivateopttemplstreamoptestgencpp_la_SOURCES = \
+	gen-cpp-private-templatestreamop/ThriftTest_types.cpp \
+	gen-cpp-private-templatestreamop/ThriftTest_types.h \
+	gen-cpp-private-templatestreamop/ThriftTest_types.tcc \
+	gen-cpp-private-templatestreamop/ThriftTest_constants.cpp \
+	gen-cpp-private-templatestreamop/ThriftTest_constants.h \
+	src/ThriftTest_extras.cpp
+
+libprivateopttemplstreamoptestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la
+
 nodist_libstresstestgencpp_la_SOURCES = \
 	gen-cpp/StressTest_types.h \
 	gen-cpp/Service.cpp \
@@ -112,7 +126,8 @@
 	ForwardSetterTest \
 	PrivateOptionalTest \
 	EnumClassTest \
-	TemplateStreamOpTest
+	TemplateStreamOpTest \
+	PrivateOptionalTemplateStreamOpTest
 
 # we currently do not run the testsuite, stop c++ server issue
 # TESTS = \
@@ -185,6 +200,14 @@
 	libtemplatestreamoptestgencpp.la \
 	$(top_builddir)/lib/cpp/libthrift.la
 
+PrivateOptionalTemplateStreamOpTest_SOURCES = \
+	src/PrivateOptionalTemplateStreamOpTest.cpp
+
+PrivateOptionalTemplateStreamOpTest_CPPFLAGS = -Igen-cpp-private-templatestreamop $(AM_CPPFLAGS)
+PrivateOptionalTemplateStreamOpTest_LDADD = \
+	libprivateopttemplstreamoptestgencpp.la \
+	$(top_builddir)/lib/cpp/libthrift.la
+
 #
 # Common thrift code generation rules
 #
@@ -211,6 +234,11 @@
 	$(MKDIR_P) gen-cpp-templatestreamop
 	$(THRIFT) --gen cpp:template_streamop -out gen-cpp-templatestreamop $<
 
+# Generate ThriftTest with private_optional,template_streamop options
+gen-cpp-private-templatestreamop/ThriftTest_types.cpp gen-cpp-private-templatestreamop/ThriftTest_types.h gen-cpp-private-templatestreamop/ThriftTest_types.tcc gen-cpp-private-templatestreamop/ThriftTest_constants.cpp: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT)
+	$(MKDIR_P) gen-cpp-private-templatestreamop
+	$(THRIFT) --gen cpp:private_optional,template_streamop -out gen-cpp-private-templatestreamop $<
+
 gen-cpp/Service.cpp: $(top_srcdir)/test/StressTest.thrift $(THRIFT)
 	$(THRIFT) --gen cpp $<
 
@@ -222,7 +250,7 @@
 AM_LDFLAGS = $(BOOST_LDFLAGS) $(LIBEVENT_LDFLAGS) $(ZLIB_LIBS)
 
 clean-local:
-	$(RM) -r gen-cpp/ gen-cpp-forward/ gen-cpp-private/ gen-cpp-enumclass/ gen-cpp-templatestreamop/
+	$(RM) -r gen-cpp/ gen-cpp-forward/ gen-cpp-private/ gen-cpp-enumclass/ gen-cpp-templatestreamop/ gen-cpp-private-templatestreamop/
 
 style-local:
 	$(CPPSTYLE_CMD)
@@ -238,4 +266,5 @@
 	src/ForwardSetterTest.cpp \
 	src/PrivateOptionalTest.cpp \
 	src/EnumClassTest.cpp \
-	src/TemplateStreamOpTest.cpp
+	src/TemplateStreamOpTest.cpp \
+	src/PrivateOptionalTemplateStreamOpTest.cpp