Skip to content

Commit

Permalink
fix space
Browse files Browse the repository at this point in the history
  • Loading branch information
iProzd committed Nov 8, 2024
1 parent e68de42 commit cef5817
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 5 additions & 0 deletions source/api_c/src/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,11 @@ template void DP_DipoleChargeModifierComputeNList_variant<float>(
* @return const char*
*/
const char* string_to_char(std::string& str) {
// Remove trailing spaces
str.erase(std::find_if(str.rbegin(), str.rend(),
[](unsigned char ch) { return !std::isspace(ch); })
.base(),
str.end());
// copy from string to char*
const std::string::size_type size = str.size();
// +1 for '\0'
Expand Down
2 changes: 0 additions & 2 deletions source/api_c/tests/test_deepspin_a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ TEST_F(TestInferDeepSpinA, numb_types_spin) {
TEST_F(TestInferDeepSpinA, type_map) {
const char* type_map = DP_DeepSpinGetTypeMap(dp);
char expected_type_map[] = "Ni O";
printf("type_map: %s\n", type_map);
printf("expected_type_map: %s\n", expected_type_map);
EXPECT_EQ(strcmp(type_map, expected_type_map), 0);
DP_DeleteChar(type_map);
}
Expand Down

0 comments on commit cef5817

Please sign in to comment.