Skip to content

Commit c2771b2

Browse files
committed
Fix include order for private member access in hftelprofile unit test
Move #define private/protected public before all #include directives to ensure hftelprofile.h is expanded with public access, even when indirectly included via mock_orchagent_main.h -> hftelorch.h. Signed-off-by: Ze Gan <[email protected]>
1 parent 6fc0c72 commit c2771b2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/mock_tests/hftelprofile_ut.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
#include "ut_helper.h"
2-
#include "mock_orchagent_main.h"
3-
#include <gtest/gtest.h>
1+
// Pre-include standard library and third-party headers that conflict with
2+
// the #define private public hack (they use 'private' internally).
3+
#include <sstream>
4+
#include <string>
5+
#include <vector>
6+
#include <map>
7+
#include <unordered_map>
8+
#include <set>
9+
#include <memory>
410

511
#define private public
612
#define protected public
713
#include "high_frequency_telemetry/hftelprofile.h"
814
#undef private
915
#undef protected
1016

17+
#include "ut_helper.h"
18+
#include "mock_orchagent_main.h"
19+
#include <gtest/gtest.h>
20+
1121
extern sai_tam_api_t *sai_tam_api;
1222

1323
namespace hftelprofile_ut
@@ -113,7 +123,7 @@ namespace hftelprofile_ut
113123

114124
/* Placement-new the containers and strings that may be
115125
* accessed (directly or via logging) by updateTemplates(). */
116-
new (&p->m_profile_name) string();
126+
new (const_cast<string*>(&p->m_profile_name)) string();
117127
new (&p->m_sai_tam_tel_type_objs)
118128
decay_t<decltype(p->m_sai_tam_tel_type_objs)>();
119129
new (&p->m_sai_tam_tel_type_templates)

0 commit comments

Comments
 (0)