-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Without this, we couldn't include `for_each.h` before generated `_for_each_field.h`. Otherwise it's build-error due to missing type. Reviewed By: iahs Differential Revision: D23250681 fbshipit-source-id: 70455a2b1c0be919c253ded55ed3b982a2ea8d0e
- Loading branch information
1 parent
a63f694
commit 76e4080
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// Test whether it works if we include for_each.h first. | ||
#include <thrift/lib/cpp2/visitation/for_each.h> | ||
|
||
#include <thrift/test/gen-cpp2/reflection_for_each_field.h> | ||
|
||
#include <folly/String.h> | ||
#include <folly/portability/GTest.h> | ||
|
||
using namespace apache::thrift; | ||
using namespace test_cpp2::cpp_reflection; | ||
|
||
TEST(structA, test) { | ||
structA s; | ||
s.a_ref() = 1; | ||
s.b_ref() = "1"; | ||
for_each_field(s, [](auto&&, auto ref) { | ||
EXPECT_EQ(folly::to<std::string>(*ref), "1"); | ||
ref = folly::to<typename decltype(ref)::value_type>(2); | ||
}); | ||
EXPECT_EQ(s.a_ref(), 2); | ||
EXPECT_EQ(s.b_ref(), "2"); | ||
} |